Commit 6cb07b57 authored by lsmith's avatar lsmith

- 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
parent 634d2d98
...@@ -304,34 +304,6 @@ class Doctrine_Hydrate ...@@ -304,34 +304,6 @@ class Doctrine_Hydrate
public function setParams(array $params = array()) { public function setParams(array $params = array()) {
$this->params = $params; $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) public function convertEnums($params)
{ {
return $params; return $params;
...@@ -381,11 +353,27 @@ class Doctrine_Hydrate ...@@ -381,11 +353,27 @@ class Doctrine_Hydrate
*/ */
public function execute($params = array(), $return = Doctrine::FETCH_RECORD) 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) { if ($this->type !== self::SELECT) {
return $this->conn->exec($query, $params); 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)) { if (empty($this->_aliasMap)) {
throw new Doctrine_Hydrate_Exception("Couldn't execute query. Component alias map was empty."); throw new Doctrine_Hydrate_Exception("Couldn't execute query. Component alias map was empty.");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment