|
|
@ -67,13 +67,15 @@ class Command extends \yii\base\Component |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public $fetchMode = \PDO::FETCH_ASSOC; |
|
|
|
public $fetchMode = \PDO::FETCH_ASSOC; |
|
|
|
/** |
|
|
|
/** |
|
|
|
* @var string the SQL statement that this command represents |
|
|
|
* @var array the parameters (name => value) that are bound to the current PDO statement. |
|
|
|
|
|
|
|
* This property is maintained by methods such as [[bindValue()]]. |
|
|
|
|
|
|
|
* Do not modify it directly. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private $_sql; |
|
|
|
public $params = []; |
|
|
|
/** |
|
|
|
/** |
|
|
|
* @var array the parameter log information (name => value) |
|
|
|
* @var string the SQL statement that this command represents |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private $_params = []; |
|
|
|
private $_sql; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns the SQL statement for this command. |
|
|
|
* Returns the SQL statement for this command. |
|
|
@ -95,7 +97,7 @@ class Command extends \yii\base\Component |
|
|
|
if ($sql !== $this->_sql) { |
|
|
|
if ($sql !== $this->_sql) { |
|
|
|
$this->cancel(); |
|
|
|
$this->cancel(); |
|
|
|
$this->_sql = $this->db->quoteSql($sql); |
|
|
|
$this->_sql = $this->db->quoteSql($sql); |
|
|
|
$this->_params = []; |
|
|
|
$this->params = []; |
|
|
|
} |
|
|
|
} |
|
|
|
return $this; |
|
|
|
return $this; |
|
|
|
} |
|
|
|
} |
|
|
@ -108,11 +110,11 @@ class Command extends \yii\base\Component |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function getRawSql() |
|
|
|
public function getRawSql() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (empty($this->_params)) { |
|
|
|
if (empty($this->params)) { |
|
|
|
return $this->_sql; |
|
|
|
return $this->_sql; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$params = []; |
|
|
|
$params = []; |
|
|
|
foreach ($this->_params as $name => $value) { |
|
|
|
foreach ($this->params as $name => $value) { |
|
|
|
if (is_string($value)) { |
|
|
|
if (is_string($value)) { |
|
|
|
$params[$name] = $this->db->quoteValue($value); |
|
|
|
$params[$name] = $this->db->quoteValue($value); |
|
|
|
} elseif ($value === null) { |
|
|
|
} elseif ($value === null) { |
|
|
@ -190,7 +192,7 @@ class Command extends \yii\base\Component |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$this->pdoStatement->bindParam($name, $value, $dataType, $length, $driverOptions); |
|
|
|
$this->pdoStatement->bindParam($name, $value, $dataType, $length, $driverOptions); |
|
|
|
} |
|
|
|
} |
|
|
|
$this->_params[$name] =& $value; |
|
|
|
$this->params[$name] =& $value; |
|
|
|
return $this; |
|
|
|
return $this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -212,7 +214,7 @@ class Command extends \yii\base\Component |
|
|
|
$dataType = $this->db->getSchema()->getPdoType($value); |
|
|
|
$dataType = $this->db->getSchema()->getPdoType($value); |
|
|
|
} |
|
|
|
} |
|
|
|
$this->pdoStatement->bindValue($name, $value, $dataType); |
|
|
|
$this->pdoStatement->bindValue($name, $value, $dataType); |
|
|
|
$this->_params[$name] = $value; |
|
|
|
$this->params[$name] = $value; |
|
|
|
return $this; |
|
|
|
return $this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -239,7 +241,7 @@ class Command extends \yii\base\Component |
|
|
|
$type = $this->db->getSchema()->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; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return $this; |
|
|
|
return $this; |
|
|
|