Support IN binding
- Dominant language
- PHP
- Stars
- 34
- Forks
- 7
- PR merge metrics
- No merged PRs in 30d
Description
None of the existing PDO implementations support binding an array to "IN" operator. I propose the following syntax:
``` php
$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.
``` php
$sth->execute(['foo' => ['1', '2', '3']]);
```
Would effectively result in:
``` php
$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.
Contributor guide
Assessment
This issue has not been assessed yet.