im trying to use array for mysql where in clause
$result= $myDB->query(\"SELECT sum(total) as total FROM \".$myDB->prefix(\"mydata\").\" WHERE categoryname
I did something similar a while ago using array_map
, hope it helps:
$args = array_map(function($a) {
return sprintf("'%s'", $a);
}, $args);
$args = join(",", $args);
The above code will iterate over the array and modifies every single element to surround it with ''
. Finally, I join the array with ,
.