doll
doll copied to clipboard
Support IN binding
None of the existing PDO implementations support binding an array to "IN" operator. I propose the following syntax:
$sth = $db->prepare("SELECT 1 FROM `foo` WHERE `name` IN (s:,foo)");
$sth = $db->prepare("SELECT 1 FROM `foo` WHERE `name` IN (:,foo)"); // or without type-hinting
In the above example ":," indicates that placeholder value is an array that needs to be imploded.
$sth->execute(['foo' => ['1', '2', '3']]);
Would effectively result in:
$sth = $db->prepare("SELECT 1 FROM `foo` WHERE `name` IN (?, ?, ?)");
$sth->execute(['1', '2', '3']);
Note that it might be that Doll will need to create a new prepared statement in case it is executed multiple times and number of array elements change.