Commit 531f4a4d authored by zYne's avatar zYne

--no commit message

--no commit message
parent 5d4b8c45
......@@ -254,7 +254,6 @@ class Doctrine_Hydrate
*/
protected function clear()
{
$this->tables = array();
$this->parts = array(
'select' => array(),
'distinct' => false,
......@@ -270,7 +269,6 @@ class Doctrine_Hydrate
'offset' => false,
);
$this->inheritanceApplied = false;
$this->tableAliases = array();
$this->aliasHandler->clear();
}
/**
......
......@@ -66,6 +66,23 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
* @var array $_enumParams an array containing the keys of the parameters that should be enumerated
*/
protected $_enumParams = array();
/**
* @var array $_dqlParts an array containing all DQL query parts
*/
protected $_dqlParts = array(
'select' => array(),
'distinct' => false,
'forUpdate' => false,
'from' => array(),
'set' => array(),
'join' => array(),
'where' => array(),
'groupby' => array(),
'having' => array(),
'orderby' => array(),
'limit' => false,
'offset' => false,
);
/**
* create
......@@ -182,7 +199,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
}
/**
* parseQueryPart
* parses given query part
* parses given DQL query part
*
* @param string $queryPartName the name of the query part
* @param string $queryPart query part to be parsed
......@@ -193,8 +210,35 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
*/
public function parseQueryPart($queryPartName, $queryPart, $append = false)
{
if ($append) {
$this->_dqlParts[$queryPartName][] = $queryPart;
} else {
$this->_dqlParts[$queryPartName] = $queryPart;
}
return $this->getParser($queryPartName)->parse($queryPart);
}
/**
* getDql
* returns the DQL query associated with this object
*
* the query is built from $_dqlParts
*
* @return string the DQL query
*/
public function getDql()
{
$q = '';
$q .= ( ! empty($this->parts['select']))? 'SELECT ' . implode(', ', $this->parts['select']) : '';
$q .= ( ! empty($this->parts['from']))? ' FROM ' . implode(' ', $this->parts['from']) : '';
$q .= ( ! empty($this->parts['where']))? ' WHERE ' . implode(' AND ', $this->parts['where']) : '';
$q .= ( ! empty($this->parts['groupby']))? ' GROUP BY ' . implode(', ', $this->parts['groupby']) : '';
$q .= ( ! empty($this->parts['having']))? ' HAVING ' . implode(' AND ', $this->parts['having']) : '';
$q .= ( ! empty($this->parts['orderby']))? ' ORDER BY ' . implode(', ', $this->parts['orderby']) : '';
$q .= ( ! empty($this->parts['limit']))? ' LIMIT ' . implode(' ', $this->parts['limit']) : '';
$q .= ( ! empty($this->parts['offset']))? ' OFFSET ' . implode(' ', $this->parts['offset']) : '';
return $q;
}
/**
* processPendingFields
* the fields in SELECT clause cannot be parsed until the components
......
......@@ -182,8 +182,8 @@ class Doctrine_RawSql extends Doctrine_Query_Abstract
$q .= ( ! empty($this->parts['from']))? ' FROM ' . implode(' ', $this->parts['from']) : '';
$q .= ( ! empty($this->parts['where']))? ' WHERE ' . implode(' AND ', $this->parts['where']) : '';
$q .= ( ! empty($this->parts['groupby']))? ' GROUP BY ' . implode(', ', $this->parts['groupby']) : '';
$q .= ( ! empty($this->parts['having']))? ' HAVING ' . implode(' ', $this->parts['having']) : '';
$q .= ( ! empty($this->parts['orderby']))? ' ORDER BY ' . implode(' ', $this->parts['orderby']) : '';
$q .= ( ! empty($this->parts['having']))? ' HAVING ' . implode(' AND ', $this->parts['having']) : '';
$q .= ( ! empty($this->parts['orderby']))? ' ORDER BY ' . implode(', ', $this->parts['orderby']) : '';
$q .= ( ! empty($this->parts['limit']))? ' LIMIT ' . implode(' ', $this->parts['limit']) : '';
$q .= ( ! empty($this->parts['offset']))? ' OFFSET ' . implode(' ', $this->parts['offset']) : '';
......
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