Closed xrayffa closed 3 years ago
That's because you are using Index Mapping not Data Mapping that the key: [array]
as the first value of column parameter.
https://medoo.in/api/select (#Index Mapping section)
The way to solve this problem:
// What is this struct for in the real production environment?
[
{
"userData": ["foo"]
},
{
"userData": ["bar"]
}
]
$data = $medoo->select('user', ['id', 'name']) 结果正常: [{"id":"1","name":"张三"}]
$data = $medoo->select('user', ['id', '映射'=> ['name']]); 结果正常: [{"id":"1","映射":{"name":"张三"}}]
$data = $medoo->select('user', [ '映射'=> ['name']]); 结果报错: Fatal error: Uncaught InvalidArgumentException: Incorrect column name "映射" in 。。。。
$data = $medoo->select('user', [ 'name'=> ['name']]); 结果异常: {"张三":{"name":"张三"} 怎么把字段的值作为键名了?
$data = $medoo->select('user', [ 'userData'=> ['name']]); 结果为空!
$data = $medoo->select('user', ['id(随便加一个存在的字段名)', 'userData'=> ['name']]); 结果正常: [{"id":"1","userData":{"name":"张三"}}] 但这样岂不是达不到数据分组的目的?