修正bindParam方法

This commit is contained in:
水平凡
2017-01-24 11:51:10 +08:00
committed by GitHub
parent 86cc9378a0
commit d8cc777e1d

View File

@@ -510,11 +510,13 @@ abstract class Connection
protected function bindParam($bind) protected function bindParam($bind)
{ {
foreach ($bind as $key => $val) { foreach ($bind as $key => $val) {
if (is_numeric($key)) { $param = is_numeric($key) ? $key + 1 : ':' . $key;
$key = $key + 1; if (is_array($val)) {
array_unshift($val, $param);
$result = call_user_func_array([$this->PDOStatement, 'bindParam'], $val);
} else {
$result = $this->PDOStatement->bindValue($param, $val);
} }
array_unshift($val, $key);
$result = call_user_func_array([$this->PDOStatement, 'bindParam'], $val);
if (!$result) { if (!$result) {
$param = array_shift($val); $param = array_shift($val);
throw new BindParamException( throw new BindParamException(