I want to bind a array of Strings to the WHERE IN
part of a SQL command, which I want to run afterwards on a SQL Server. The problem is probably that I try to bind
You could use some string manipulation.
You can count
the number of ?
you'd need by using str_repeat("?", count(explode(",", $refIdsPartial)))
. This will create your placeholders.
$totalCount =
"SELECT referral, COUNT(username) AS cnt FROM accounts
WHERE referral IN (". str_repeat("?,", count(explode(",", $refIdsPartial))-1) . "?) GROUP BY referral";
Now that the placeholders are in place, you can explode the ,
from the string and execute
$ps_totalCounts->execute( explode(",", $refIdsPartial) );