Hiya,
Hopefully a quick one this.
I am creating a plugin that has a query in it which will bring back multiple results.
Once I have those results I want to create a comma separated string from them. I thought that I would just be able to do something like this but it’s not working :
$query = $DB->query("SELECT member_id FROM exp_members");
$comma_separated_ids = implode(",", $query);N.B. This isn’t the actual query I’m running but just an example.
Can this sort of thing not be done like this? Do I have to use a for each loop or something? I’d really rather not have to if I don’t though. I just wanted to be able to take the database queries results array (I take it the results are in an array aren’t they?) and straight convert it into that kind of string.
Any help would be greatly appreciated.
Many thanks.
Best wishes,
Mark
Oops sorry also meant to mention that the reason I need this as a string is that I want to then use it in another query as part of an IN clause such as :
SELECT *
FROM exp_member_data
WHERE member_id IN ($comma_separated_ids)That kind of thing.
Any help would be appreciated on this.
Best wishes,
Mark
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.