Binds a value to a parameter.
public bindValue ( string | integer $name, mixed $value, integer $dataType = null ) | ||
$name | string | integer | Parameter identifier. For a prepared statement using named placeholders, this will be a parameter name of the form `:name`. For a prepared statement using question mark placeholders, this will be the 1-indexed position of the parameter. |
$value | mixed | The value to bind to the parameter |
$dataType | integer | SQL data type of the parameter. If null, the type is determined by the PHP type of the value. |
/** * Binds a value to a parameter. * @param string|integer $name Parameter identifier. For a prepared statement * using named placeholders, this will be a parameter name of * the form `:name`. For a prepared statement using question mark * placeholders, this will be the 1-indexed position of the parameter. * @param mixed $value The value to bind to the parameter * @param integer $dataType SQL data type of the parameter. If null, the type is determined by the PHP type of the value. * @return static the current command being executed * @see http://www.php.net/manual/en/function.PDOStatement-bindValue.php */ public function bindValue($name, $value, $dataType = null) { if ($dataType === null) { $dataType = $this->db->getSchema()->getPdoType($value); } if ($dataType == \PDO::PARAM_BOOL) { $dataType = \PDO::PARAM_INT; } return parent::bindValue($name, $value, $dataType); }
/** * @inheritdoc */ public function bindValue($name, $value, $dataType = null) { if ($this->db->enableFloatConversion && $dataType === null && is_float($value)) { $this->floatParams[$name] = $value; return $this; } return parent::bindValue($name, $value, $dataType); }