return group_concat data as array

匿名 (未验证) 提交于 2019-12-03 08:36:05

问题:

I want to return values I retrieve from the db using group_concat as an array of data. Is it possible to do this in the mysql query? Or do I need to explode the data into an array?

GROUP_CONCAT(sh.hold_id) as holds 

returns this

[holds] => 3,4 

I want it to return:

[holds] => array(3,4) 

回答1:

As I said in my comment: you need to explode the data into an array, using php code like this:

$holds = explode(',', $holds); 

because mysql has no concept of array-type for data.



回答2:

MySQL has no concept of arrays. Therefore it is not able to return an array. It is up to your processing code (here the php scripts) to convert the concatenated notation into a php array.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!