|
|
@ -144,7 +144,7 @@ class Command extends \yii\base\Component |
|
|
|
{ |
|
|
|
{ |
|
|
|
$this->prepare(); |
|
|
|
$this->prepare(); |
|
|
|
if ($dataType === null) { |
|
|
|
if ($dataType === null) { |
|
|
|
$this->pdoStatement->bindParam($name, $value, $this->connection->getPdoType(gettype($value))); |
|
|
|
$this->pdoStatement->bindParam($name, $value, $this->getPdoType(gettype($value))); |
|
|
|
} elseif ($length === null) { |
|
|
|
} elseif ($length === null) { |
|
|
|
$this->pdoStatement->bindParam($name, $value, $dataType); |
|
|
|
$this->pdoStatement->bindParam($name, $value, $dataType); |
|
|
|
} elseif ($driverOptions === null) { |
|
|
|
} elseif ($driverOptions === null) { |
|
|
@ -171,7 +171,7 @@ class Command extends \yii\base\Component |
|
|
|
{ |
|
|
|
{ |
|
|
|
$this->prepare(); |
|
|
|
$this->prepare(); |
|
|
|
if ($dataType === null) { |
|
|
|
if ($dataType === null) { |
|
|
|
$this->pdoStatement->bindValue($name, $value, $this->connection->getPdoType(gettype($value))); |
|
|
|
$this->pdoStatement->bindValue($name, $value, $this->getPdoType(gettype($value))); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$this->pdoStatement->bindValue($name, $value, $dataType); |
|
|
|
$this->pdoStatement->bindValue($name, $value, $dataType); |
|
|
|
} |
|
|
|
} |
|
|
@ -199,7 +199,7 @@ class Command extends \yii\base\Component |
|
|
|
$type = $value[1]; |
|
|
|
$type = $value[1]; |
|
|
|
$value = $value[0]; |
|
|
|
$value = $value[0]; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$type = $this->connection->getPdoType(gettype($value)); |
|
|
|
$type = $this->getPdoType(gettype($value)); |
|
|
|
} |
|
|
|
} |
|
|
|
$this->pdoStatement->bindValue($name, $value, $type); |
|
|
|
$this->pdoStatement->bindValue($name, $value, $type); |
|
|
|
$this->_params[$name] = $value; |
|
|
|
$this->_params[$name] = $value; |
|
|
@ -209,6 +209,23 @@ class Command extends \yii\base\Component |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
|
|
|
|
* Determines the PDO type for the give PHP data type. |
|
|
|
|
|
|
|
* @param string $type The PHP type (obtained by `gettype()` call). |
|
|
|
|
|
|
|
* @return integer the corresponding PDO type |
|
|
|
|
|
|
|
* @see http://www.php.net/manual/en/pdo.constants.php |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private function getPdoType($type) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
static $typeMap = array( |
|
|
|
|
|
|
|
'boolean' => \PDO::PARAM_BOOL, |
|
|
|
|
|
|
|
'integer' => \PDO::PARAM_INT, |
|
|
|
|
|
|
|
'string' => \PDO::PARAM_STR, |
|
|
|
|
|
|
|
'NULL' => \PDO::PARAM_NULL, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
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. |
|
|
|