Binding a parameter by reference does not support DBAL mapping types.
public bindParam ( string $name, mixed &$var, integer $type = PDO::PARAM_STR, integer | null $length = null ) : boolean | ||
$name | string | The name or position of the parameter. |
$var | mixed | The reference to the variable to bind. |
$type | integer | The PDO binding type. |
$length | integer | null | Must be specified when using an OUT bind so that PHP allocates enough memory to hold the returned value. |
Résultat | boolean | TRUE on success, FALSE on failure. |
/** * Performs binding of variables bound with bindValue and bindParam on the statement $stmt. * * This method must be called if you have used the bind methods * in your query and you build the method yourself using build. * * @param \Doctrine\DBAL\Statement $stmt */ private function doBind(Statement $stmt) { foreach ($this->boundValues as $key => $value) { $stmt->bindValue($key, $value, $this->boundValuesType[$key]); } foreach ($this->boundParameters as $key => &$value) { $stmt->bindParam($key, $value, $this->boundParametersType[$key]); } }
/** * Биндит значения плейсхолдеров * @param Statement $preparedStatement * @param string $query SQL, сформированный билдером для текущего запроса * (например, подзапроса, вложенного в основной) */ protected function bind(Statement $preparedStatement, $query) { foreach ($this->values as $placeholder => $value) { if (strpos($query, $placeholder) !== false) { $preparedStatement->bindValue($placeholder, $value[0], $value[1]); } } foreach ($this->variables as $placeholder => $value) { if (strpos($query, $placeholder) !== false) { $variable =& $value[0]; $preparedStatement->bindParam($placeholder, $variable, $value[1]); } } foreach ($this->arrays as $placeholder => $values) { $count = count($values); for ($i = 0; $i < $count; $i++) { $value = $values[$i]; $nextPlaceholder = $placeholder . $i; if (is_null($value)) { $preparedStatement->bindValue($nextPlaceholder, $value, \PDO::PARAM_NULL); } elseif (is_int($value)) { $preparedStatement->bindValue($nextPlaceholder, $value, \PDO::PARAM_INT); } else { $preparedStatement->bindValue($nextPlaceholder, $value, \PDO::PARAM_STR); } } } }
/** * @param $name * @param $var * @param int $type * @param null $length * @return mixed */ public function bindParam($name, &$var, $type = PDO::PARAM_STR, $length = null) { return $this->stmt->bindParam($name, $var, $type, $length); }