- 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
@ -151,11 +151,11 @@ class Doctrine_Hydrate
|
|||||||
}
|
}
|
||||||
public function getDeclaration($name)
|
public function getDeclaration($name)
|
||||||
{
|
{
|
||||||
if ( ! isset($this->_aliasMap[$name])) {
|
if ( ! isset($this->_aliasMap[$name])) {
|
||||||
throw new Doctrine_Hydrate_Exception('Unknown component alias ' . $name);
|
throw new Doctrine_Hydrate_Exception('Unknown component alias ' . $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->_aliasMap[$name];
|
return $this->_aliasMap[$name];
|
||||||
}
|
}
|
||||||
public function setQueryPart($name, $part)
|
public function setQueryPart($name, $part)
|
||||||
{
|
{
|
||||||
@ -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;
|
||||||
@ -354,7 +326,7 @@ class Doctrine_Hydrate
|
|||||||
*/
|
*/
|
||||||
public function mapAggregateValues($record, array $row, $alias)
|
public function mapAggregateValues($record, array $row, $alias)
|
||||||
{
|
{
|
||||||
$found = false;
|
$found = false;
|
||||||
// aggregate values have numeric keys
|
// aggregate values have numeric keys
|
||||||
if (isset($row[0])) {
|
if (isset($row[0])) {
|
||||||
// map each aggregate value
|
// map each aggregate value
|
||||||
@ -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)
|
||||||
{
|
{
|
||||||
if ($this->type !== self::SELECT) {
|
$params = $this->conn->convertBooleans(array_merge($this->params, $params));
|
||||||
return $this->conn->exec($query, $params);
|
$params = $this->convertEnums($params);
|
||||||
}
|
|
||||||
|
|
||||||
$array = (array) $this->_fetch($params, $return = Doctrine::FETCH_RECORD);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
$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.");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user