Details
Description
Prerequisites:
1. Detection of this mode has to be super-fast. It should not have an auto-detection but should be triggered explicitly.
2. This mode cannot be supported after $conn->prepare(). It is only viable for $conn->executeQuery() or $conn->executeUpdate().
Case 1: Positional
$stmt = $conn->executeQuery("SELECT a.id FROM articles a WHERE a.id IN (?) AND a.foo = ?",
array($paramList, $foo), array( Connection::PARAM_ARRAY => PDO::PARAM_INT) , PDO:PARAM_STR ),
Connection::FLAG_EXPAND_ARRAYS
);
Would internally, right before execution, be rewritten to:
$c = count($paramList); // 3! "SELECT a.id FROM articles a WHERE a.id IN (?, ?, ?) AND a.foo = ?"
Case 2: Named
$stmt = $conn->executeQuery("SELECT a.id FROM articles a WHERE a.id IN (:id) AND a.foo = :bar",
array('id' => $paramList, 'bar' => $foo),
array( array(Connection::PARAM_ARRAY => PDO::PARAM_INT), PDO::PARAM_STR ),
Connection::FLAG_EXPAND_ARRAYS
);
Would internally, right before execution, be rewritten to:
$c = count($paramList); // 3! "SELECT a.id FROM articles a WHERE a.id IN (:id1, :id2, :id3) AND a.foo = :bar"
Implementing this for Named parameters is not really possible without re-parsing the query after every replacement just because the named parameters can occur more then once and this messes with the positions.