|
|
@ -181,8 +181,9 @@ class Command extends \yii\base\Component |
|
|
|
{ |
|
|
|
{ |
|
|
|
$this->prepare(); |
|
|
|
$this->prepare(); |
|
|
|
if ($dataType === null) { |
|
|
|
if ($dataType === null) { |
|
|
|
$this->pdoStatement->bindParam($name, $value, $this->getPdoType($value)); |
|
|
|
$dataType = $this->db->getSchema()->getPdoType($value); |
|
|
|
} elseif ($length === null) { |
|
|
|
} |
|
|
|
|
|
|
|
if ($length === null) { |
|
|
|
$this->pdoStatement->bindParam($name, $value, $dataType); |
|
|
|
$this->pdoStatement->bindParam($name, $value, $dataType); |
|
|
|
} elseif ($driverOptions === null) { |
|
|
|
} elseif ($driverOptions === null) { |
|
|
|
$this->pdoStatement->bindParam($name, $value, $dataType, $length); |
|
|
|
$this->pdoStatement->bindParam($name, $value, $dataType, $length); |
|
|
@ -208,10 +209,9 @@ class Command extends \yii\base\Component |
|
|
|
{ |
|
|
|
{ |
|
|
|
$this->prepare(); |
|
|
|
$this->prepare(); |
|
|
|
if ($dataType === null) { |
|
|
|
if ($dataType === null) { |
|
|
|
$this->pdoStatement->bindValue($name, $value, $this->getPdoType($value)); |
|
|
|
$dataType = $this->db->getSchema()->getPdoType($value); |
|
|
|
} else { |
|
|
|
|
|
|
|
$this->pdoStatement->bindValue($name, $value, $dataType); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
$this->pdoStatement->bindValue($name, $value, $dataType); |
|
|
|
$this->_params[$name] = $value; |
|
|
|
$this->_params[$name] = $value; |
|
|
|
return $this; |
|
|
|
return $this; |
|
|
|
} |
|
|
|
} |
|
|
@ -236,7 +236,7 @@ class Command extends \yii\base\Component |
|
|
|
$type = $value[1]; |
|
|
|
$type = $value[1]; |
|
|
|
$value = $value[0]; |
|
|
|
$value = $value[0]; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$type = $this->getPdoType($value); |
|
|
|
$type = $this->db->getSchema()->getPdoType($value); |
|
|
|
} |
|
|
|
} |
|
|
|
$this->pdoStatement->bindValue($name, $value, $type); |
|
|
|
$this->pdoStatement->bindValue($name, $value, $type); |
|
|
|
$this->_params[$name] = $value; |
|
|
|
$this->_params[$name] = $value; |
|
|
@ -246,25 +246,6 @@ class Command extends \yii\base\Component |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Determines the PDO type for the given PHP data value. |
|
|
|
|
|
|
|
* @param mixed $data the data whose PDO type is to be determined |
|
|
|
|
|
|
|
* @return integer the PDO type |
|
|
|
|
|
|
|
* @see http://www.php.net/manual/en/pdo.constants.php |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
protected function getPdoType($data) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
static $typeMap = array( // php type => PDO type |
|
|
|
|
|
|
|
'boolean' => \PDO::PARAM_BOOL, |
|
|
|
|
|
|
|
'integer' => \PDO::PARAM_INT, |
|
|
|
|
|
|
|
'string' => \PDO::PARAM_STR, |
|
|
|
|
|
|
|
'resource' => \PDO::PARAM_LOB, |
|
|
|
|
|
|
|
'NULL' => \PDO::PARAM_NULL, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
$type = gettype($data); |
|
|
|
|
|
|
|
return isset($typeMap[$type]) ? $typeMap[$type] : \PDO::PARAM_STR; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Executes the SQL statement. |
|
|
|
* Executes the SQL statement. |
|
|
|
* This method should only be used for executing non-query SQL statement, such as `INSERT`, `DELETE`, `UPDATE` SQLs. |
|
|
|
* This method should only be used for executing non-query SQL statement, such as `INSERT`, `DELETE`, `UPDATE` SQLs. |
|
|
|
* No result set will be returned. |
|
|
|
* No result set will be returned. |
|
|
|