php - php。向数组添加新列,但结果加倍
问题描述
我想要做的是在数组中添加一个新列,这样我就可以将这两列放入其中:
uuid1。'-' 。uuid2
它正在做的是将结果加倍,例如:
$base = \Query::Create()
->Database('main')
->Select(
'devices.id',
'devices.uuid1',
'devices.uuid2')
->From('devices')
->where(column('deleted_on'), is, new \DBNull())
->limit(5);
try {
$MySqlItems = $base->Execute();
foreach ($MySqlItems as $list_item) {
$list_item['result'] = "";
array_push($MySqlItems, $list_item);
}
} catch(\Exception $ex) {}
从另一个页面:
$response['MySql'] = $MySqlData;
结果:
"MySql": [
{
"id": "64",
"uuid1": "1318",
"uuid2": "52366"
},
{
"id": "296",
"uuid1": "17304",
"uuid2": "10994"
},
{
"id": "445",
"uuid1": "17488",
"uuid2": "57404"
},
{
"id": "64",
"uuid1": "1318",
"uuid2": "52366",
"result": "1318-52366" What I want the result to be like.
},
{
"id": "296",
"uuid1": "17304",
"uuid2": "10994",
"result":
},
{
"id": "445",
"uuid1": "17488",
"uuid2": "57404",
"result":
}
]
关于我在这里做错了什么的任何想法?
解决方案
在你的mysql上试试这个,你会明白你的问题的
create table Test(id integer, title varchar(100));
insert into Test(id, title) values(1, "Hello");
select id, title, concat(id, '-', title)result from Test;
推荐阅读
- bash - Bash 获取使用 head 命令提取的文件列表的大小
- python - 在python中使用线程(多处理)时传递变量
- angular - 如何在http get中传递查询参数
- java - snapshot.getvalue(double.class) 的拆箱可能会产生空指针异常
- css - 如何使图像高度超过容器的高度,以使图像与其他元素/组件重叠?
- javascript - 如何在反应原生地图中拖动我当前的位置标记?
- docker - Docker Stack 部署组合无法正常工作
- java - 无法再在任何 IDE 上运行 JavaFX
- angular - Angular 应用程序无法在 Docker 中启动,缺少 angular-devkit package.json
- java - 如何测试以查看 java Junit 5 中的抽象方法?