Commit c5b4c9e6 authored by Benjamin Eberlei's avatar Benjamin Eberlei

Merge remote-tracking branch 'origin/pr/264' into DBAL-435

parents 89c3e54c bf4e8439
...@@ -130,11 +130,13 @@ class SQLParserUtils ...@@ -130,11 +130,13 @@ class SQLParserUtils
$types = array_merge( $types = array_merge(
array_slice($types, 0, $needle), array_slice($types, 0, $needle),
array_fill(0, $count, $types[$needle] - Connection::ARRAY_PARAM_OFFSET), // array needles are at PDO::PARAM_* + 100 $count ?
array_fill(0, $count, $types[$needle] - Connection::ARRAY_PARAM_OFFSET) : // array needles are at PDO::PARAM_* + 100
array(),
array_slice($types, $needle + 1) array_slice($types, $needle + 1)
); );
$expandStr = implode(", ", array_fill(0, $count, "?")); $expandStr = $count ? implode(", ", array_fill(0, $count, "?")) : 'NULL';
$query = substr($query, 0, $needlePos) . $expandStr . substr($query, $needlePos + 1); $query = substr($query, 0, $needlePos) . $expandStr . substr($query, $needlePos + 1);
$paramOffset += ($count - 1); // Grows larger by number of parameters minus the replaced needle. $paramOffset += ($count - 1); // Grows larger by number of parameters minus the replaced needle.
...@@ -164,7 +166,7 @@ class SQLParserUtils ...@@ -164,7 +166,7 @@ class SQLParserUtils
} }
$count = count($value); $count = count($value);
$expandStr = $count > 0 ? implode(', ', array_fill(0, $count, '?')) : '?'; $expandStr = $count > 0 ? implode(', ', array_fill(0, $count, '?')) : 'NULL';
foreach ($value as $val) { foreach ($value as $val) {
$paramsOrd[] = $val; $paramsOrd[] = $val;
...@@ -197,4 +199,4 @@ class SQLParserUtils ...@@ -197,4 +199,4 @@ class SQLParserUtils
return $fragments[1]; return $fragments[1];
} }
} }
\ No newline at end of file
...@@ -108,21 +108,21 @@ SQLDATA ...@@ -108,21 +108,21 @@ SQLDATA
array(1, 2, 3, 4, 5), array(1, 2, 3, 4, 5),
array(\PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT) array(\PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT)
), ),
// Positional : Empty "integer" array DDC-1978 // Positional: Empty "integer" array DDC-1978
array( array(
"SELECT * FROM Foo WHERE foo IN (?)", "SELECT * FROM Foo WHERE foo IN (?)",
array('foo'=>array()), array(array()),
array('foo'=>Connection::PARAM_INT_ARRAY), array(Connection::PARAM_INT_ARRAY),
'SELECT * FROM Foo WHERE foo IN (?)', 'SELECT * FROM Foo WHERE foo IN (NULL)',
array(), array(),
array() array()
), ),
// Positional : Empty "str" array DDC-1978 // Positional: Empty "str" array DDC-1978
array( array(
"SELECT * FROM Foo WHERE foo IN (?)", "SELECT * FROM Foo WHERE foo IN (?)",
array('foo'=>array()), array(array()),
array('foo'=>Connection::PARAM_STR_ARRAY), array(Connection::PARAM_STR_ARRAY),
'SELECT * FROM Foo WHERE foo IN (?)', 'SELECT * FROM Foo WHERE foo IN (NULL)',
array(), array(),
array() array()
), ),
...@@ -145,7 +145,6 @@ SQLDATA ...@@ -145,7 +145,6 @@ SQLDATA
array(1,'Some String'), array(1,'Some String'),
array(\PDO::PARAM_INT, \PDO::PARAM_STR) array(\PDO::PARAM_INT, \PDO::PARAM_STR)
), ),
// Named parameters : Very simple with one needle // Named parameters : Very simple with one needle
array( array(
"SELECT * FROM Foo WHERE foo IN (:foo)", "SELECT * FROM Foo WHERE foo IN (:foo)",
...@@ -224,7 +223,7 @@ SQLDATA ...@@ -224,7 +223,7 @@ SQLDATA
"SELECT * FROM Foo WHERE foo IN (:foo)", "SELECT * FROM Foo WHERE foo IN (:foo)",
array('foo'=>array()), array('foo'=>array()),
array('foo'=>Connection::PARAM_INT_ARRAY), array('foo'=>Connection::PARAM_INT_ARRAY),
'SELECT * FROM Foo WHERE foo IN (?)', 'SELECT * FROM Foo WHERE foo IN (NULL)',
array(), array(),
array() array()
), ),
...@@ -233,7 +232,7 @@ SQLDATA ...@@ -233,7 +232,7 @@ SQLDATA
"SELECT * FROM Foo WHERE foo IN (:foo) OR bar IN (:bar)", "SELECT * FROM Foo WHERE foo IN (:foo) OR bar IN (:bar)",
array('foo'=>array(), 'bar'=>array()), array('foo'=>array(), 'bar'=>array()),
array('foo'=>Connection::PARAM_STR_ARRAY, 'bar'=>Connection::PARAM_STR_ARRAY), array('foo'=>Connection::PARAM_STR_ARRAY, 'bar'=>Connection::PARAM_STR_ARRAY),
'SELECT * FROM Foo WHERE foo IN (?) OR bar IN (?)', 'SELECT * FROM Foo WHERE foo IN (NULL) OR bar IN (NULL)',
array(), array(),
array() array()
), ),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment