Group_concat and then explode it into an array

I group_concat a bunch of reviews from my db that turns it into something like this:

This is review 1, this is review 2

then I will explode it into an array like:

$review = $row->review;
$row->review = explode(',', $review);

      

This works great until someone in this review adds ,

, then this obsoulvy doesn't work anymore. So is there a way to group_concat and put something other than a comma in between? Is there a better way to fix this? Any ideas would be greatly appreciated.

+3


source to share


1 answer


Yes, don't use GROUP_CONCAT

. Create a sub-table containing views and related relationships linking each view to whatever objects you deal with.



If you already have this, and just use GROUP_CONCAT

to fetch multiple reviews into one result set ... then don't use anyway GROUP_CONCAT

. Use a subquery.

+2


source







All Articles