- fixed handling of non select queries
- moved code from _fetch() back into execute() as a result (maybe move the code after parseData() into a private function in order to keep the method size manageable
This commit is contained in:
parent
634d2d9834
commit
6cb07b57e6
@ -304,34 +304,6 @@ class Doctrine_Hydrate
|
||||
public function setParams(array $params = array()) {
|
||||
$this->params = $params;
|
||||
}
|
||||
/**
|
||||
* _fetch
|
||||
*
|
||||
* @param array $params prepared statement parameters
|
||||
* @param integer $fetchMode the fetchmode
|
||||
* @see Doctrine::FETCH_* constants
|
||||
*/
|
||||
public function _fetch($params = array(), $fetchMode = Doctrine::FETCH_RECORD)
|
||||
{
|
||||
$params = $this->conn->convertBooleans(array_merge($this->params, $params));
|
||||
$params = $this->convertEnums($params);
|
||||
|
||||
if ( ! $this->_view) {
|
||||
$query = $this->getQuery($params);
|
||||
} else {
|
||||
$query = $this->_view->getSelectSql();
|
||||
}
|
||||
|
||||
if ($this->isLimitSubqueryUsed() &&
|
||||
$this->conn->getDBH()->getAttribute(Doctrine::ATTR_DRIVER_NAME) !== 'mysql') {
|
||||
|
||||
$params = array_merge($params, $params);
|
||||
}
|
||||
|
||||
$stmt = $this->conn->execute($query, $params);
|
||||
|
||||
return $this->parseData($stmt);
|
||||
}
|
||||
public function convertEnums($params)
|
||||
{
|
||||
return $params;
|
||||
@ -381,11 +353,27 @@ class Doctrine_Hydrate
|
||||
*/
|
||||
public function execute($params = array(), $return = Doctrine::FETCH_RECORD)
|
||||
{
|
||||
$params = $this->conn->convertBooleans(array_merge($this->params, $params));
|
||||
$params = $this->convertEnums($params);
|
||||
|
||||
if ( ! $this->_view) {
|
||||
$query = $this->getQuery($params);
|
||||
} else {
|
||||
$query = $this->_view->getSelectSql();
|
||||
}
|
||||
|
||||
if ($this->isLimitSubqueryUsed() &&
|
||||
$this->conn->getDBH()->getAttribute(Doctrine::ATTR_DRIVER_NAME) !== 'mysql') {
|
||||
|
||||
$params = array_merge($params, $params);
|
||||
}
|
||||
|
||||
if ($this->type !== self::SELECT) {
|
||||
return $this->conn->exec($query, $params);
|
||||
}
|
||||
|
||||
$array = (array) $this->_fetch($params, $return = Doctrine::FETCH_RECORD);
|
||||
$stmt = $this->conn->execute($query, $params);
|
||||
$array = (array) $this->parseData($stmt);
|
||||
|
||||
if (empty($this->_aliasMap)) {
|
||||
throw new Doctrine_Hydrate_Exception("Couldn't execute query. Component alias map was empty.");
|
||||
|
Loading…
x
Reference in New Issue
Block a user