2007-07-24 15:34:00 +04:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* $Id: Query.php 1393 2007-05-19 17:49:16Z zYne $
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* This software consists of voluntary contributions made by many individuals
|
|
|
|
* and is licensed under the LGPL. For more information, see
|
2008-01-23 01:52:53 +03:00
|
|
|
* <http://www.phpdoctrine.org>.
|
2007-07-24 15:34:00 +04:00
|
|
|
*/
|
2007-12-06 22:02:29 +03:00
|
|
|
|
2007-07-24 15:34:00 +04:00
|
|
|
/**
|
|
|
|
* Doctrine_Query_Abstract
|
|
|
|
*
|
|
|
|
* @package Doctrine
|
2007-10-04 01:43:22 +04:00
|
|
|
* @subpackage Query
|
2007-07-24 15:34:00 +04:00
|
|
|
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
|
|
|
* @link www.phpdoctrine.com
|
|
|
|
* @since 1.0
|
|
|
|
* @version $Revision: 1393 $
|
|
|
|
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
2007-11-24 21:11:09 +03:00
|
|
|
* @todo See {@link Doctrine_Query}
|
2007-07-24 15:34:00 +04:00
|
|
|
*/
|
2007-11-20 17:26:42 +03:00
|
|
|
abstract class Doctrine_Query_Abstract
|
2007-07-24 15:34:00 +04:00
|
|
|
{
|
2007-11-20 17:26:42 +03:00
|
|
|
/**
|
|
|
|
* QUERY TYPE CONSTANTS
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* constant for SELECT queries
|
|
|
|
*/
|
|
|
|
const SELECT = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* constant for DELETE queries
|
|
|
|
*/
|
|
|
|
const DELETE = 1;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* constant for UPDATE queries
|
|
|
|
*/
|
|
|
|
const UPDATE = 2;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* constant for INSERT queries
|
|
|
|
*/
|
|
|
|
const INSERT = 3;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* constant for CREATE queries
|
|
|
|
*/
|
|
|
|
const CREATE = 4;
|
|
|
|
|
|
|
|
/** @todo document the query states (and the transitions between them). */
|
2007-11-24 21:11:09 +03:00
|
|
|
/**
|
|
|
|
* A query object is in CLEAN state when it has NO unparsed/unprocessed DQL parts.
|
|
|
|
*/
|
2007-11-20 17:26:42 +03:00
|
|
|
const STATE_CLEAN = 1;
|
2007-11-24 21:11:09 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A query object is in state DIRTY when it has DQL parts that have not yet been
|
|
|
|
* parsed/processed.
|
|
|
|
*/
|
2007-11-20 17:26:42 +03:00
|
|
|
const STATE_DIRTY = 2;
|
2007-11-24 21:11:09 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A query is in DIRECT state when ... ?
|
|
|
|
*/
|
2007-11-20 17:26:42 +03:00
|
|
|
const STATE_DIRECT = 3;
|
|
|
|
|
2007-11-24 21:11:09 +03:00
|
|
|
/**
|
|
|
|
* A query object is on LOCKED state when ... ?
|
|
|
|
*/
|
|
|
|
const STATE_LOCKED = 4;
|
2007-11-20 17:26:42 +03:00
|
|
|
|
2007-11-24 21:11:09 +03:00
|
|
|
/**
|
|
|
|
* @var array Table alias map. Keys are SQL aliases and values DQL aliases.
|
|
|
|
*/
|
|
|
|
protected $_tableAliasMap = array();
|
2007-11-20 17:26:42 +03:00
|
|
|
|
2007-11-24 21:11:09 +03:00
|
|
|
/**
|
|
|
|
* @var Doctrine_View The view object used by this query, if any.
|
|
|
|
*/
|
2007-11-20 17:26:42 +03:00
|
|
|
protected $_view;
|
2007-11-24 21:11:09 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var integer $_state The current state of this query.
|
|
|
|
*/
|
|
|
|
protected $_state = Doctrine_Query::STATE_CLEAN;
|
2007-11-20 17:26:42 +03:00
|
|
|
|
|
|
|
/**
|
2007-11-24 21:11:09 +03:00
|
|
|
* @var array $params The parameters of this query.
|
2007-11-20 17:26:42 +03:00
|
|
|
*/
|
2007-12-26 23:52:37 +03:00
|
|
|
protected $_params = array('join' => array(),
|
|
|
|
'where' => array(),
|
2007-11-20 17:26:42 +03:00
|
|
|
'set' => array(),
|
|
|
|
'having' => array());
|
|
|
|
|
|
|
|
/* Caching properties */
|
2007-11-24 21:11:09 +03:00
|
|
|
/**
|
|
|
|
* @var Doctrine_Cache_Interface The cache driver used for caching result sets.
|
|
|
|
*/
|
|
|
|
protected $_resultCache;
|
2007-11-20 17:26:42 +03:00
|
|
|
/**
|
2007-11-24 21:11:09 +03:00
|
|
|
* @var boolean $_expireResultCache A boolean value that indicates whether or not
|
|
|
|
* expire the result cache.
|
|
|
|
*/
|
|
|
|
protected $_expireResultCache = false;
|
|
|
|
protected $_resultCacheTTL;
|
2007-11-20 17:26:42 +03:00
|
|
|
|
2007-11-24 21:11:09 +03:00
|
|
|
/**
|
|
|
|
* @var Doctrine_Cache_Interface The cache driver used for caching queries.
|
2007-11-20 17:26:42 +03:00
|
|
|
*/
|
2007-11-24 21:11:09 +03:00
|
|
|
protected $_queryCache;
|
|
|
|
protected $_expireQueryCache = false;
|
|
|
|
protected $_queryCacheTTL;
|
|
|
|
|
2007-11-20 17:26:42 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var Doctrine_Connection The connection used by this query object.
|
|
|
|
*/
|
|
|
|
protected $_conn;
|
|
|
|
|
2007-11-24 21:11:09 +03:00
|
|
|
|
2007-11-20 17:26:42 +03:00
|
|
|
/**
|
2007-11-24 21:11:09 +03:00
|
|
|
* @var array $_sqlParts The SQL query string parts. Filled during the DQL parsing process.
|
|
|
|
*/
|
|
|
|
protected $_sqlParts = array(
|
2007-11-20 17:26:42 +03:00
|
|
|
'select' => array(),
|
|
|
|
'distinct' => false,
|
|
|
|
'forUpdate' => false,
|
|
|
|
'from' => array(),
|
|
|
|
'set' => array(),
|
|
|
|
'join' => array(),
|
|
|
|
'where' => array(),
|
|
|
|
'groupby' => array(),
|
|
|
|
'having' => array(),
|
|
|
|
'orderby' => array(),
|
|
|
|
'limit' => false,
|
|
|
|
'offset' => false,
|
|
|
|
);
|
|
|
|
|
2007-11-24 21:11:09 +03:00
|
|
|
/**
|
2008-01-05 22:55:56 +03:00
|
|
|
* @var array $_dqlParts An array containing all DQL query parts.
|
2007-11-24 21:11:09 +03:00
|
|
|
*/
|
|
|
|
protected $_dqlParts = array(
|
2008-01-05 22:55:56 +03:00
|
|
|
'from' => array(),
|
|
|
|
'select' => array(),
|
|
|
|
'forUpdate' => false,
|
|
|
|
'set' => array(),
|
|
|
|
'join' => array(),
|
|
|
|
'where' => array(),
|
|
|
|
'groupby' => array(),
|
|
|
|
'having' => array(),
|
|
|
|
'orderby' => array(),
|
|
|
|
'limit' => array(),
|
|
|
|
'offset' => array(),
|
|
|
|
);
|
2007-11-24 21:11:09 +03:00
|
|
|
|
2007-11-20 17:26:42 +03:00
|
|
|
|
|
|
|
/**
|
2007-11-24 21:11:09 +03:00
|
|
|
* @var array $_queryComponents Two dimensional array containing the components of this query,
|
|
|
|
* informations about their relations and other related information.
|
|
|
|
* The components are constructed during query parsing.
|
|
|
|
*
|
|
|
|
* Keys are component aliases and values the following:
|
2007-11-20 17:26:42 +03:00
|
|
|
*
|
|
|
|
* table table object associated with given alias
|
|
|
|
*
|
|
|
|
* relation the relation object owned by the parent
|
|
|
|
*
|
|
|
|
* parent the alias of the parent
|
|
|
|
*
|
|
|
|
* agg the aggregates of this component
|
|
|
|
*
|
|
|
|
* map the name of the column / aggregate value this
|
|
|
|
* component is mapped to a collection
|
|
|
|
*/
|
2007-11-24 21:11:09 +03:00
|
|
|
protected $_queryComponents = array();
|
2007-11-20 17:26:42 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var integer $type the query type
|
|
|
|
*
|
|
|
|
* @see Doctrine_Query::* constants
|
|
|
|
*/
|
2007-11-24 21:11:09 +03:00
|
|
|
protected $_type = self::SELECT;
|
2007-11-20 17:26:42 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var Doctrine_Hydrator The hydrator object used to hydrate query results.
|
|
|
|
*/
|
|
|
|
protected $_hydrator;
|
|
|
|
|
2007-11-24 21:11:09 +03:00
|
|
|
/**
|
|
|
|
* @var Doctrine_Query_Tokenizer The tokenizer that is used during the query parsing process.
|
|
|
|
*/
|
|
|
|
protected $_tokenizer;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var Doctrine_Query_Parser The parser that is used for query parsing.
|
|
|
|
*/
|
|
|
|
protected $_parser;
|
|
|
|
|
2007-11-20 17:26:42 +03:00
|
|
|
/**
|
|
|
|
* @var array $_tableAliasSeeds A simple array keys representing table aliases and values
|
2007-11-24 21:11:09 +03:00
|
|
|
* table alias seeds. The seeds are used for generating short table
|
2007-11-20 17:26:42 +03:00
|
|
|
* aliases.
|
|
|
|
*/
|
|
|
|
protected $_tableAliasSeeds = array();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var array $_options an array of options
|
|
|
|
*/
|
|
|
|
protected $_options = array(
|
2007-11-24 21:11:09 +03:00
|
|
|
'fetchMode' => Doctrine::FETCH_RECORD
|
2007-11-20 17:26:42 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var array $_enumParams an array containing the keys of the parameters that should be enumerated
|
|
|
|
*/
|
|
|
|
protected $_enumParams = array();
|
|
|
|
|
2007-11-24 21:58:33 +03:00
|
|
|
/**
|
|
|
|
* @var boolean
|
|
|
|
*/
|
2007-11-24 21:11:09 +03:00
|
|
|
protected $_isLimitSubqueryUsed = false;
|
|
|
|
|
2007-11-20 17:26:42 +03:00
|
|
|
|
2007-11-24 21:11:09 +03:00
|
|
|
/**
|
2007-11-24 21:58:33 +03:00
|
|
|
* Constructor.
|
2007-11-24 21:11:09 +03:00
|
|
|
*
|
2007-11-24 21:58:33 +03:00
|
|
|
* @param Doctrine_Connection The connection object the query will use.
|
|
|
|
* @param Doctrine_Hydrator_Abstract The hydrator that will be used for generating result sets.
|
2007-11-24 21:11:09 +03:00
|
|
|
*/
|
2007-11-20 17:26:42 +03:00
|
|
|
public function __construct(Doctrine_Connection $connection = null,
|
|
|
|
Doctrine_Hydrator_Abstract $hydrator = null)
|
|
|
|
{
|
|
|
|
if ($connection === null) {
|
|
|
|
$connection = Doctrine_Manager::getInstance()->getCurrentConnection();
|
|
|
|
}
|
|
|
|
if ($hydrator === null) {
|
2007-11-25 18:57:08 +03:00
|
|
|
$hydrator = new Doctrine_Hydrator();
|
2007-11-20 17:26:42 +03:00
|
|
|
}
|
|
|
|
$this->_conn = $connection;
|
|
|
|
$this->_hydrator = $hydrator;
|
2007-11-24 21:11:09 +03:00
|
|
|
$this->_tokenizer = new Doctrine_Query_Tokenizer();
|
2007-11-20 17:26:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* setOption
|
|
|
|
*
|
|
|
|
* @param string $name option name
|
|
|
|
* @param string $value option value
|
|
|
|
* @return Doctrine_Query this object
|
|
|
|
*/
|
|
|
|
public function setOption($name, $value)
|
|
|
|
{
|
|
|
|
if ( ! isset($this->_options[$name])) {
|
|
|
|
throw new Doctrine_Query_Exception('Unknown option ' . $name);
|
|
|
|
}
|
|
|
|
$this->_options[$name] = $value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* hasTableAlias
|
|
|
|
* whether or not this object has given tableAlias
|
|
|
|
*
|
|
|
|
* @param string $tableAlias the table alias to be checked
|
|
|
|
* @return boolean true if this object has given alias, otherwise false
|
2007-11-24 21:11:09 +03:00
|
|
|
* @deprecated
|
|
|
|
*/
|
|
|
|
public function hasTableAlias($sqlTableAlias)
|
|
|
|
{
|
|
|
|
return $this->hasSqlTableAlias($sqlTableAlias);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* hasSqlTableAlias
|
|
|
|
* whether or not this object has given tableAlias
|
|
|
|
*
|
|
|
|
* @param string $tableAlias the table alias to be checked
|
|
|
|
* @return boolean true if this object has given alias, otherwise false
|
2007-11-20 17:26:42 +03:00
|
|
|
*/
|
2007-11-24 21:11:09 +03:00
|
|
|
public function hasSqlTableAlias($sqlTableAlias)
|
2007-11-20 17:26:42 +03:00
|
|
|
{
|
2007-11-24 21:11:09 +03:00
|
|
|
return (isset($this->_tableAliasMap[$sqlTableAlias]));
|
2007-11-20 17:26:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* getTableAliases
|
|
|
|
* returns all table aliases
|
|
|
|
*
|
|
|
|
* @return array table aliases as an array
|
2007-11-24 21:11:09 +03:00
|
|
|
* @deprecated
|
2007-11-20 17:26:42 +03:00
|
|
|
*/
|
|
|
|
public function getTableAliases()
|
|
|
|
{
|
2007-11-24 21:11:09 +03:00
|
|
|
return $this->getTableAliasMap();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* getTableAliasMap
|
|
|
|
* returns all table aliases
|
|
|
|
*
|
|
|
|
* @return array table aliases as an array
|
|
|
|
*/
|
|
|
|
public function getTableAliasMap()
|
|
|
|
{
|
|
|
|
return $this->_tableAliasMap;
|
2007-11-20 17:26:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* getQueryPart
|
|
|
|
* gets a query part from the query part array
|
|
|
|
*
|
|
|
|
* @param string $name the name of the query part to be set
|
|
|
|
* @param string $part query part string
|
2007-11-24 21:11:09 +03:00
|
|
|
* @throws Doctrine_Query_Exception if trying to set unknown query part
|
|
|
|
* @return Doctrine_Query_Abstract this object
|
|
|
|
* @deprecated
|
2007-11-20 17:26:42 +03:00
|
|
|
*/
|
|
|
|
public function getQueryPart($part)
|
|
|
|
{
|
2007-11-24 21:11:09 +03:00
|
|
|
return $this->getSqlQueryPart($part);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* getSqlQueryPart
|
|
|
|
* gets an SQL query part from the SQL query part array
|
|
|
|
*
|
|
|
|
* @param string $name the name of the query part to be set
|
|
|
|
* @param string $part query part string
|
|
|
|
* @throws Doctrine_Query_Exception if trying to set unknown query part
|
|
|
|
* @return Doctrine_Hydrate this object
|
|
|
|
*/
|
|
|
|
public function getSqlQueryPart($part)
|
|
|
|
{
|
|
|
|
if ( ! isset($this->_sqlParts[$part])) {
|
|
|
|
throw new Doctrine_Query_Exception('Unknown SQL query part ' . $part);
|
2007-11-20 17:26:42 +03:00
|
|
|
}
|
2007-11-24 21:11:09 +03:00
|
|
|
return $this->_sqlParts[$part];
|
2007-11-20 17:26:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* setQueryPart
|
|
|
|
* sets a query part in the query part array
|
|
|
|
*
|
|
|
|
* @param string $name the name of the query part to be set
|
|
|
|
* @param string $part query part string
|
2007-11-24 21:11:09 +03:00
|
|
|
* @throws Doctrine_Query_Exception if trying to set unknown query part
|
2007-11-20 17:26:42 +03:00
|
|
|
* @return Doctrine_Hydrate this object
|
2007-11-24 21:11:09 +03:00
|
|
|
* @deprecated
|
2007-11-20 17:26:42 +03:00
|
|
|
*/
|
|
|
|
public function setQueryPart($name, $part)
|
|
|
|
{
|
2007-11-24 21:11:09 +03:00
|
|
|
return $this->setSqlQueryPart($name, $part);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* setSqlQueryPart
|
|
|
|
* sets an SQL query part in the SQL query part array
|
|
|
|
*
|
|
|
|
* @param string $name the name of the query part to be set
|
|
|
|
* @param string $part query part string
|
|
|
|
* @throws Doctrine_Query_Exception if trying to set unknown query part
|
|
|
|
* @return Doctrine_Hydrate this object
|
|
|
|
*/
|
|
|
|
public function setSqlQueryPart($name, $part)
|
|
|
|
{
|
|
|
|
if ( ! isset($this->_sqlParts[$name])) {
|
|
|
|
throw new Doctrine_Query_Exception('Unknown query part ' . $name);
|
2007-11-20 17:26:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($name !== 'limit' && $name !== 'offset') {
|
|
|
|
if (is_array($part)) {
|
2007-11-24 21:11:09 +03:00
|
|
|
$this->_sqlParts[$name] = $part;
|
2007-11-20 17:26:42 +03:00
|
|
|
} else {
|
2007-11-24 21:11:09 +03:00
|
|
|
$this->_sqlParts[$name] = array($part);
|
2007-11-20 17:26:42 +03:00
|
|
|
}
|
|
|
|
} else {
|
2007-11-24 21:11:09 +03:00
|
|
|
$this->_sqlParts[$name] = $part;
|
2007-11-20 17:26:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* addQueryPart
|
|
|
|
* adds a query part in the query part array
|
|
|
|
*
|
|
|
|
* @param string $name the name of the query part to be added
|
|
|
|
* @param string $part query part string
|
2007-11-24 21:11:09 +03:00
|
|
|
* @throws Doctrine_Query_Exception if trying to add unknown query part
|
2007-11-20 17:26:42 +03:00
|
|
|
* @return Doctrine_Hydrate this object
|
2007-11-24 21:11:09 +03:00
|
|
|
* @deprecated
|
2007-11-20 17:26:42 +03:00
|
|
|
*/
|
|
|
|
public function addQueryPart($name, $part)
|
|
|
|
{
|
2007-11-24 21:11:09 +03:00
|
|
|
return $this->addSqlQueryPart($name, $part);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* addSqlQueryPart
|
|
|
|
* adds an SQL query part to the SQL query part array
|
|
|
|
*
|
|
|
|
* @param string $name the name of the query part to be added
|
|
|
|
* @param string $part query part string
|
|
|
|
* @throws Doctrine_Query_Exception if trying to add unknown query part
|
|
|
|
* @return Doctrine_Hydrate this object
|
|
|
|
*/
|
|
|
|
public function addSqlQueryPart($name, $part)
|
|
|
|
{
|
|
|
|
if ( ! isset($this->_sqlParts[$name])) {
|
|
|
|
throw new Doctrine_Query_Exception('Unknown query part ' . $name);
|
2007-11-20 17:26:42 +03:00
|
|
|
}
|
|
|
|
if (is_array($part)) {
|
2007-11-24 21:11:09 +03:00
|
|
|
$this->_sqlParts[$name] = array_merge($this->_sqlParts[$name], $part);
|
2007-11-20 17:26:42 +03:00
|
|
|
} else {
|
2007-11-24 21:11:09 +03:00
|
|
|
$this->_sqlParts[$name][] = $part;
|
2007-11-20 17:26:42 +03:00
|
|
|
}
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* removeQueryPart
|
|
|
|
* removes a query part from the query part array
|
|
|
|
*
|
|
|
|
* @param string $name the name of the query part to be removed
|
2007-11-24 21:11:09 +03:00
|
|
|
* @throws Doctrine_Query_Exception if trying to remove unknown query part
|
2007-11-20 17:26:42 +03:00
|
|
|
* @return Doctrine_Hydrate this object
|
2007-11-24 21:11:09 +03:00
|
|
|
* @deprecated
|
2007-11-20 17:26:42 +03:00
|
|
|
*/
|
|
|
|
public function removeQueryPart($name)
|
|
|
|
{
|
2007-11-24 21:11:09 +03:00
|
|
|
return $this->removeSqlQueryPart($name);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* removeSqlQueryPart
|
|
|
|
* removes a query part from the query part array
|
|
|
|
*
|
|
|
|
* @param string $name the name of the query part to be removed
|
|
|
|
* @throws Doctrine_Query_Exception if trying to remove unknown query part
|
|
|
|
* @return Doctrine_Hydrate this object
|
|
|
|
*/
|
|
|
|
public function removeSqlQueryPart($name)
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
if ( ! isset($this->_sqlParts[$name])) {
|
|
|
|
throw new Doctrine_Query_Exception('Unknown query part ' . $name);
|
|
|
|
}}
|
|
|
|
catch (Exception $e) {echo $e->getTraceAsString(); echo "<br /><br /><br />";}
|
2007-11-20 17:26:42 +03:00
|
|
|
|
|
|
|
if ($name == 'limit' || $name == 'offset') {
|
2007-11-24 21:11:09 +03:00
|
|
|
$this->_sqlParts[$name] = false;
|
2007-11-20 17:26:42 +03:00
|
|
|
} else {
|
2007-11-24 21:11:09 +03:00
|
|
|
$this->_sqlParts[$name] = array();
|
2007-11-20 17:26:42 +03:00
|
|
|
}
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* setView
|
|
|
|
* sets a database view this query object uses
|
|
|
|
* this method should only be called internally by doctrine
|
|
|
|
*
|
|
|
|
* @param Doctrine_View $view database view
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function setView(Doctrine_View $view)
|
|
|
|
{
|
|
|
|
$this->_view = $view;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* getView
|
|
|
|
* returns the view associated with this query object (if any)
|
|
|
|
*
|
|
|
|
* @return Doctrine_View the view associated with this query object
|
|
|
|
*/
|
|
|
|
public function getView()
|
|
|
|
{
|
|
|
|
return $this->_view;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* limitSubqueryUsed
|
|
|
|
*
|
|
|
|
* @return boolean
|
|
|
|
*/
|
|
|
|
public function isLimitSubqueryUsed()
|
|
|
|
{
|
2007-11-24 21:11:09 +03:00
|
|
|
return $this->_isLimitSubqueryUsed;
|
2007-11-20 17:26:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* convertEnums
|
|
|
|
* convert enum parameters to their integer equivalents
|
|
|
|
*
|
|
|
|
* @return array converted parameter array
|
|
|
|
*/
|
|
|
|
public function convertEnums($params)
|
|
|
|
{
|
|
|
|
foreach ($this->_enumParams as $key => $values) {
|
|
|
|
if (isset($params[$key])) {
|
|
|
|
if ( ! empty($values)) {
|
|
|
|
$params[$key] = $values[0]->enumIndex($values[1], $params[$key]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $params;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-01-05 22:55:56 +03:00
|
|
|
* Creates the SQL snippet for additional joins.
|
|
|
|
*
|
|
|
|
* @return string The created SQL snippet.
|
|
|
|
*/
|
|
|
|
protected function _createCustomJoinSql($componentName, $componentAlias)
|
|
|
|
{
|
|
|
|
$table = $this->_conn->getTable($componentName);
|
|
|
|
$tableAlias = $this->getSqlTableAlias($componentAlias, $table->getTableName());
|
|
|
|
$customJoins = $this->_conn->getMapper($componentName)->getCustomJoins();
|
|
|
|
$sql = '';
|
2008-01-12 22:49:11 +03:00
|
|
|
foreach ($customJoins as $componentName => $joinType) {
|
2008-01-05 22:55:56 +03:00
|
|
|
$joinedTable = $this->_conn->getTable($componentName);
|
|
|
|
$joinedAlias = $componentAlias . '.' . $componentName;
|
|
|
|
$joinedTableAlias = $this->getSqlTableAlias($joinedAlias, $joinedTable->getTableName());
|
2008-01-12 22:49:11 +03:00
|
|
|
$sql .= " $joinType JOIN " . $this->_conn->quoteIdentifier($joinedTable->getTableName())
|
2008-01-05 22:55:56 +03:00
|
|
|
. ' ' . $this->_conn->quoteIdentifier($joinedTableAlias) . ' ON ';
|
|
|
|
|
|
|
|
foreach ($table->getIdentifierColumnNames() as $column) {
|
|
|
|
$sql .= $this->_conn->quoteIdentifier($tableAlias)
|
|
|
|
. '.' . $this->_conn->quoteIdentifier($column)
|
|
|
|
. ' = ' . $this->_conn->quoteIdentifier($joinedTableAlias)
|
|
|
|
. '.' . $this->_conn->quoteIdentifier($column);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $sql;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates the SQL snippet for the WHERE part that contains the discriminator
|
|
|
|
* column conditions.
|
2007-11-20 17:26:42 +03:00
|
|
|
*
|
2008-01-05 22:55:56 +03:00
|
|
|
* @return string The created SQL snippet.
|
2007-11-20 17:26:42 +03:00
|
|
|
*/
|
2008-01-12 22:49:11 +03:00
|
|
|
protected function _createDiscriminatorConditionSql()
|
|
|
|
{
|
2007-11-20 17:26:42 +03:00
|
|
|
$array = array();
|
2007-11-24 21:11:09 +03:00
|
|
|
foreach ($this->_queryComponents as $componentAlias => $data) {
|
2008-01-12 22:49:11 +03:00
|
|
|
$sqlTableAlias = $this->getSqlTableAlias($componentAlias);
|
|
|
|
if ( ! $data['mapper'] instanceof Doctrine_Mapper_SingleTable) {
|
|
|
|
$array[$sqlTableAlias][] = array();
|
|
|
|
} else {
|
|
|
|
$array[$sqlTableAlias][] = $data['mapper']->getDiscriminatorColumn();
|
|
|
|
}
|
2007-11-20 17:26:42 +03:00
|
|
|
}
|
2008-01-05 22:55:56 +03:00
|
|
|
//var_dump($array);
|
2007-11-20 17:26:42 +03:00
|
|
|
// apply inheritance maps
|
|
|
|
$str = '';
|
|
|
|
$c = array();
|
|
|
|
|
|
|
|
$index = 0;
|
|
|
|
foreach ($array as $tableAlias => $maps) {
|
|
|
|
$a = array();
|
|
|
|
|
|
|
|
// don't use table aliases if the query isn't a select query
|
2007-11-24 21:11:09 +03:00
|
|
|
if ($this->_type !== Doctrine_Query::SELECT) {
|
2007-11-20 17:26:42 +03:00
|
|
|
$tableAlias = '';
|
|
|
|
} else {
|
|
|
|
$tableAlias .= '.';
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($maps as $map) {
|
|
|
|
$b = array();
|
|
|
|
foreach ($map as $field => $value) {
|
|
|
|
$identifier = $this->_conn->quoteIdentifier($tableAlias . $field);
|
|
|
|
|
|
|
|
if ($index > 0) {
|
|
|
|
$b[] = '(' . $identifier . ' = ' . $this->_conn->quote($value)
|
|
|
|
. ' OR ' . $identifier . ' IS NULL)';
|
|
|
|
} else {
|
|
|
|
$b[] = $identifier . ' = ' . $this->_conn->quote($value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ! empty($b)) {
|
|
|
|
$a[] = implode(' AND ', $b);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ! empty($a)) {
|
|
|
|
$c[] = implode(' AND ', $a);
|
|
|
|
}
|
|
|
|
$index++;
|
|
|
|
}
|
|
|
|
|
|
|
|
$str .= implode(' AND ', $c);
|
|
|
|
|
|
|
|
return $str;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* getTableAlias
|
|
|
|
* some database such as Oracle need the identifier lengths to be < ~30 chars
|
|
|
|
* hence Doctrine creates as short identifier aliases as possible
|
|
|
|
*
|
|
|
|
* this method is used for the creation of short table aliases, its also
|
|
|
|
* smart enough to check if an alias already exists for given component (componentAlias)
|
|
|
|
*
|
|
|
|
* @param string $componentAlias the alias for the query component to search table alias for
|
|
|
|
* @param string $tableName the table name from which the table alias is being created
|
|
|
|
* @return string the generated / fetched short alias
|
2007-11-24 21:11:09 +03:00
|
|
|
* @deprecated
|
2007-11-20 17:26:42 +03:00
|
|
|
*/
|
|
|
|
public function getTableAlias($componentAlias, $tableName = null)
|
|
|
|
{
|
2007-11-24 21:11:09 +03:00
|
|
|
return $this->getSqlTableAlias($componentAlias, $tableName);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* getSqlTableAlias
|
|
|
|
* some database such as Oracle need the identifier lengths to be < ~30 chars
|
|
|
|
* hence Doctrine creates as short identifier aliases as possible
|
|
|
|
*
|
|
|
|
* this method is used for the creation of short table aliases, its also
|
|
|
|
* smart enough to check if an alias already exists for given component (componentAlias)
|
|
|
|
*
|
|
|
|
* @param string $componentAlias the alias for the query component to search table alias for
|
|
|
|
* @param string $tableName the table name from which the table alias is being created
|
|
|
|
* @return string the generated / fetched short alias
|
|
|
|
*/
|
|
|
|
public function getSqlTableAlias($componentAlias, $tableName = null)
|
|
|
|
{
|
|
|
|
$alias = array_search($componentAlias, $this->_tableAliasMap);
|
2007-11-20 17:26:42 +03:00
|
|
|
|
|
|
|
if ($alias !== false) {
|
|
|
|
return $alias;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($tableName === null) {
|
2007-11-24 21:11:09 +03:00
|
|
|
throw new Doctrine_Query_Exception("Couldn't get short alias for " . $componentAlias);
|
2007-11-20 17:26:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return $this->generateTableAlias($componentAlias, $tableName);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* generateNewTableAlias
|
|
|
|
* generates a new alias from given table alias
|
|
|
|
*
|
|
|
|
* @param string $tableAlias table alias from which to generate the new alias from
|
|
|
|
* @return string the created table alias
|
2007-11-24 21:11:09 +03:00
|
|
|
* @deprecated
|
2007-11-20 17:26:42 +03:00
|
|
|
*/
|
2007-11-24 21:11:09 +03:00
|
|
|
public function generateNewTableAlias($oldAlias)
|
2007-11-20 17:26:42 +03:00
|
|
|
{
|
2007-11-24 21:11:09 +03:00
|
|
|
return $this->generateNewSqlTableAlias($oldAlias);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* generateNewSqlTableAlias
|
|
|
|
* generates a new alias from given table alias
|
|
|
|
*
|
|
|
|
* @param string $tableAlias table alias from which to generate the new alias from
|
|
|
|
* @return string the created table alias
|
|
|
|
*/
|
|
|
|
public function generateNewSqlTableAlias($oldAlias)
|
|
|
|
{
|
|
|
|
if (isset($this->_tableAliasMap[$oldAlias])) {
|
2007-11-20 17:26:42 +03:00
|
|
|
// generate a new alias
|
2007-11-24 21:11:09 +03:00
|
|
|
$name = substr($oldAlias, 0, 1);
|
|
|
|
$i = ((int) substr($oldAlias, 1));
|
2007-11-20 17:26:42 +03:00
|
|
|
|
|
|
|
if ($i == 0) {
|
|
|
|
$i = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
$newIndex = ($this->_tableAliasSeeds[$name] + $i);
|
|
|
|
|
|
|
|
return $name . $newIndex;
|
|
|
|
}
|
|
|
|
|
2007-11-24 21:11:09 +03:00
|
|
|
return $oldAlias;
|
2007-11-20 17:26:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* getTableAliasSeed
|
|
|
|
* returns the alias seed for given table alias
|
|
|
|
*
|
|
|
|
* @param string $tableAlias table alias that identifies the alias seed
|
|
|
|
* @return integer table alias seed
|
2007-11-24 21:11:09 +03:00
|
|
|
* @deprecated
|
|
|
|
*/
|
|
|
|
public function getTableAliasSeed($sqlTableAlias)
|
|
|
|
{
|
|
|
|
return $this->getSqlTableAliasSeed($sqlTableAlias);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* getSqlTableAliasSeed
|
|
|
|
* returns the alias seed for given table alias
|
|
|
|
*
|
|
|
|
* @param string $tableAlias table alias that identifies the alias seed
|
|
|
|
* @return integer table alias seed
|
2007-11-20 17:26:42 +03:00
|
|
|
*/
|
2007-11-24 21:11:09 +03:00
|
|
|
public function getSqlTableAliasSeed($sqlTableAlias)
|
2007-11-20 17:26:42 +03:00
|
|
|
{
|
2007-11-24 21:11:09 +03:00
|
|
|
if ( ! isset($this->_tableAliasSeeds[$sqlTableAlias])) {
|
2007-11-20 17:26:42 +03:00
|
|
|
return 0;
|
|
|
|
}
|
2007-11-24 21:11:09 +03:00
|
|
|
return $this->_tableAliasSeeds[$sqlTableAlias];
|
2007-11-20 17:26:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* hasAliasDeclaration
|
|
|
|
* whether or not this object has a declaration for given component alias
|
|
|
|
*
|
|
|
|
* @param string $componentAlias the component alias the retrieve the declaration from
|
|
|
|
* @return boolean
|
|
|
|
*/
|
|
|
|
public function hasAliasDeclaration($componentAlias)
|
|
|
|
{
|
2007-11-24 21:11:09 +03:00
|
|
|
return isset($this->_queryComponents[$componentAlias]);
|
2007-11-20 17:26:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* getAliasDeclaration
|
|
|
|
* get the declaration for given component alias
|
|
|
|
*
|
|
|
|
* @param string $componentAlias the component alias the retrieve the declaration from
|
|
|
|
* @return array the alias declaration
|
2007-11-24 21:11:09 +03:00
|
|
|
* @deprecated
|
2007-11-20 17:26:42 +03:00
|
|
|
*/
|
|
|
|
public function getAliasDeclaration($componentAlias)
|
|
|
|
{
|
2007-11-24 21:11:09 +03:00
|
|
|
return $this->getQueryComponent($componentAlias);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* getQueryComponent
|
|
|
|
* get the declaration for given component alias
|
|
|
|
*
|
|
|
|
* @param string $componentAlias the component alias the retrieve the declaration from
|
|
|
|
* @return array the alias declaration
|
|
|
|
*/
|
|
|
|
public function getQueryComponent($componentAlias)
|
|
|
|
{
|
|
|
|
if ( ! isset($this->_queryComponents[$componentAlias])) {
|
|
|
|
throw new Doctrine_Query_Exception('Unknown component alias ' . $componentAlias);
|
2007-11-20 17:26:42 +03:00
|
|
|
}
|
|
|
|
|
2007-11-24 21:11:09 +03:00
|
|
|
return $this->_queryComponents[$componentAlias];
|
2007-11-20 17:26:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* copyAliases
|
|
|
|
* copy aliases from another Hydrate object
|
|
|
|
*
|
|
|
|
* this method is needed by DQL subqueries which need the aliases
|
|
|
|
* of the parent query
|
|
|
|
*
|
|
|
|
* @param Doctrine_Hydrate $query the query object from which the
|
|
|
|
* aliases are copied from
|
|
|
|
* @return Doctrine_Hydrate this object
|
|
|
|
*/
|
|
|
|
public function copyAliases(Doctrine_Query_Abstract $query)
|
|
|
|
{
|
2007-11-24 21:11:09 +03:00
|
|
|
$this->_tableAliasMap = $query->_tableAliasMap;
|
|
|
|
$this->_queryComponents = $query->_queryComponents;
|
2007-11-20 17:26:42 +03:00
|
|
|
$this->_tableAliasSeeds = $query->_tableAliasSeeds;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* getRootAlias
|
|
|
|
* returns the alias of the the root component
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function getRootAlias()
|
|
|
|
{
|
2007-11-24 21:11:09 +03:00
|
|
|
if ( ! $this->_queryComponents) {
|
2007-11-20 17:26:42 +03:00
|
|
|
$this->getSql();
|
|
|
|
}
|
2007-11-24 21:11:09 +03:00
|
|
|
reset($this->_queryComponents);
|
2007-11-20 17:26:42 +03:00
|
|
|
|
2007-11-24 21:11:09 +03:00
|
|
|
return key($this->_queryComponents);
|
2007-11-20 17:26:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* getRootDeclaration
|
|
|
|
* returns the root declaration
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function getRootDeclaration()
|
|
|
|
{
|
2007-11-24 21:11:09 +03:00
|
|
|
$map = reset($this->_queryComponents);
|
2007-11-20 17:26:42 +03:00
|
|
|
return $map;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* getRoot
|
|
|
|
* returns the root component for this object
|
|
|
|
*
|
|
|
|
* @return Doctrine_Table root components table
|
|
|
|
*/
|
|
|
|
public function getRoot()
|
|
|
|
{
|
2007-11-24 21:11:09 +03:00
|
|
|
$map = reset($this->_queryComponents);
|
2007-11-20 17:26:42 +03:00
|
|
|
|
|
|
|
if ( ! isset($map['table'])) {
|
2007-11-24 21:11:09 +03:00
|
|
|
throw new Doctrine_Query_Exception('Root component not initialized.');
|
2007-11-20 17:26:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return $map['table'];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* generateTableAlias
|
|
|
|
* generates a table alias from given table name and associates
|
|
|
|
* it with given component alias
|
|
|
|
*
|
|
|
|
* @param string $componentAlias the component alias to be associated with generated table alias
|
|
|
|
* @param string $tableName the table name from which to generate the table alias
|
|
|
|
* @return string the generated table alias
|
2007-11-24 21:11:09 +03:00
|
|
|
* @deprecated
|
2007-11-20 17:26:42 +03:00
|
|
|
*/
|
|
|
|
public function generateTableAlias($componentAlias, $tableName)
|
2007-11-24 21:11:09 +03:00
|
|
|
{
|
|
|
|
return $this->generateSqlTableAlias($componentAlias, $tableName);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* generateSqlTableAlias
|
|
|
|
* generates a table alias from given table name and associates
|
|
|
|
* it with given component alias
|
|
|
|
*
|
|
|
|
* @param string $componentAlias the component alias to be associated with generated table alias
|
|
|
|
* @param string $tableName the table name from which to generate the table alias
|
|
|
|
* @return string the generated table alias
|
|
|
|
*/
|
|
|
|
public function generateSqlTableAlias($componentAlias, $tableName)
|
2007-11-20 17:26:42 +03:00
|
|
|
{
|
|
|
|
$char = strtolower(substr($tableName, 0, 1));
|
|
|
|
|
|
|
|
$alias = $char;
|
|
|
|
|
|
|
|
if ( ! isset($this->_tableAliasSeeds[$alias])) {
|
|
|
|
$this->_tableAliasSeeds[$alias] = 1;
|
|
|
|
}
|
|
|
|
|
2007-11-24 21:11:09 +03:00
|
|
|
while (isset($this->_tableAliasMap[$alias])) {
|
2007-11-20 17:26:42 +03:00
|
|
|
if ( ! isset($this->_tableAliasSeeds[$alias])) {
|
|
|
|
$this->_tableAliasSeeds[$alias] = 1;
|
|
|
|
}
|
|
|
|
$alias = $char . ++$this->_tableAliasSeeds[$alias];
|
|
|
|
}
|
|
|
|
|
2007-11-24 21:11:09 +03:00
|
|
|
$this->_tableAliasMap[$alias] = $componentAlias;
|
2007-11-20 17:26:42 +03:00
|
|
|
|
|
|
|
return $alias;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* getComponentAlias
|
|
|
|
* get component alias associated with given table alias
|
|
|
|
*
|
2007-11-24 21:11:09 +03:00
|
|
|
* @param string $sqlTableAlias the SQL table alias that identifies the component alias
|
2007-11-20 17:26:42 +03:00
|
|
|
* @return string component alias
|
|
|
|
*/
|
2007-11-24 21:11:09 +03:00
|
|
|
public function getComponentAlias($sqlTableAlias)
|
2007-11-20 17:26:42 +03:00
|
|
|
{
|
2007-11-24 21:11:09 +03:00
|
|
|
if ( ! isset($this->_tableAliasMap[$sqlTableAlias])) {
|
|
|
|
throw new Doctrine_Query_Exception('Unknown table alias ' . $sqlTableAlias);
|
2007-11-20 17:26:42 +03:00
|
|
|
}
|
2007-11-24 21:11:09 +03:00
|
|
|
return $this->_tableAliasMap[$sqlTableAlias];
|
2007-11-20 17:26:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* _execute
|
|
|
|
*
|
|
|
|
* @param array $params
|
2007-11-25 18:57:08 +03:00
|
|
|
* @return PDOStatement The executed PDOStatement.
|
2007-11-20 17:26:42 +03:00
|
|
|
*/
|
2007-11-24 21:11:09 +03:00
|
|
|
protected function _execute($params)
|
2007-11-20 17:26:42 +03:00
|
|
|
{
|
|
|
|
$params = $this->_conn->convertBooleans($params);
|
|
|
|
|
|
|
|
if ( ! $this->_view) {
|
2007-11-25 22:07:30 +03:00
|
|
|
if ($this->_queryCache || $this->_conn->getAttribute(Doctrine::ATTR_QUERY_CACHE)) {
|
2007-11-25 18:57:08 +03:00
|
|
|
$queryCacheDriver = $this->getQueryCacheDriver();
|
|
|
|
// calculate hash for dql query
|
|
|
|
$dql = $this->getDql();
|
2007-11-25 22:07:30 +03:00
|
|
|
$hash = md5($dql . 'DOCTRINE_QUERY_CACHE_SALT');
|
2007-11-25 18:57:08 +03:00
|
|
|
$cached = $queryCacheDriver->fetch($hash);
|
|
|
|
if ($cached) {
|
|
|
|
$query = $this->_constructQueryFromCache($cached);
|
|
|
|
} else {
|
|
|
|
$query = $this->getSqlQuery($params);
|
|
|
|
$serializedQuery = $this->getCachedForm($query);
|
|
|
|
$queryCacheDriver->save($hash, $serializedQuery, $this->_queryCacheTTL);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$query = $this->getSqlQuery($params);
|
|
|
|
}
|
2007-11-20 17:26:42 +03:00
|
|
|
} else {
|
|
|
|
$query = $this->_view->getSelectSql();
|
|
|
|
}
|
|
|
|
|
|
|
|
$params = $this->convertEnums($params);
|
|
|
|
|
|
|
|
if ($this->isLimitSubqueryUsed() &&
|
2007-11-24 21:11:09 +03:00
|
|
|
$this->_conn->getAttribute(Doctrine::ATTR_DRIVER_NAME) !== 'mysql') {
|
2007-11-20 17:26:42 +03:00
|
|
|
$params = array_merge($params, $params);
|
|
|
|
}
|
|
|
|
|
2007-11-24 21:11:09 +03:00
|
|
|
if ($this->_type !== self::SELECT) {
|
2007-11-20 17:26:42 +03:00
|
|
|
return $this->_conn->exec($query, $params);
|
|
|
|
}
|
2007-11-25 18:57:08 +03:00
|
|
|
|
2007-11-20 17:26:42 +03:00
|
|
|
$stmt = $this->_conn->execute($query, $params);
|
2008-01-05 22:55:56 +03:00
|
|
|
|
2007-11-20 17:26:42 +03:00
|
|
|
return $stmt;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* execute
|
|
|
|
* executes the query and populates the data set
|
|
|
|
*
|
|
|
|
* @param string $params
|
|
|
|
* @return Doctrine_Collection the root collection
|
|
|
|
*/
|
|
|
|
public function execute($params = array(), $hydrationMode = null)
|
|
|
|
{
|
2007-12-26 23:52:37 +03:00
|
|
|
$params = array_merge($this->_params['join'],
|
|
|
|
$this->_params['set'],
|
2007-11-20 17:26:42 +03:00
|
|
|
$this->_params['where'],
|
|
|
|
$this->_params['having'],
|
|
|
|
$params);
|
2007-11-24 21:11:09 +03:00
|
|
|
|
|
|
|
if ($this->_resultCache) {
|
|
|
|
$cacheDriver = $this->getResultCacheDriver();
|
2007-11-20 17:26:42 +03:00
|
|
|
|
2007-11-24 21:11:09 +03:00
|
|
|
$dql = $this->getDql();
|
2007-11-20 17:26:42 +03:00
|
|
|
// calculate hash for dql query
|
|
|
|
$hash = md5($dql . var_export($params, true));
|
|
|
|
|
2007-11-24 21:11:09 +03:00
|
|
|
$cached = ($this->_expireResultCache) ? false : $cacheDriver->fetch($hash);
|
2007-11-20 17:26:42 +03:00
|
|
|
|
|
|
|
if ($cached === false) {
|
|
|
|
// cache miss
|
|
|
|
$stmt = $this->_execute($params);
|
2007-11-24 21:11:09 +03:00
|
|
|
$this->_hydrator->setQueryComponents($this->_queryComponents);
|
2007-11-25 18:57:08 +03:00
|
|
|
$result = $this->_hydrator->hydrateResultSet($stmt, $this->_tableAliasMap,
|
2007-11-21 17:29:59 +03:00
|
|
|
Doctrine::HYDRATE_ARRAY);
|
2007-11-20 17:26:42 +03:00
|
|
|
|
2007-11-25 18:57:08 +03:00
|
|
|
$cached = $this->getCachedForm($result);
|
2007-11-24 21:11:09 +03:00
|
|
|
$cacheDriver->save($hash, $cached, $this->_resultCacheTTL);
|
2007-11-25 18:57:08 +03:00
|
|
|
return $result;
|
2007-11-20 17:26:42 +03:00
|
|
|
} else {
|
2007-11-25 18:57:08 +03:00
|
|
|
return $this->_constructQueryFromCache($cached);
|
2007-11-20 17:26:42 +03:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$stmt = $this->_execute($params);
|
|
|
|
|
|
|
|
if (is_integer($stmt)) {
|
|
|
|
return $stmt;
|
|
|
|
}
|
|
|
|
|
2007-11-24 21:11:09 +03:00
|
|
|
$this->_hydrator->setQueryComponents($this->_queryComponents);
|
2007-11-25 18:57:08 +03:00
|
|
|
return $this->_hydrator->hydrateResultSet($stmt, $this->_tableAliasMap, $hydrationMode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructs the query from the cached form.
|
|
|
|
*
|
|
|
|
* @param string The cached query, in a serialized form.
|
|
|
|
* @return array The custom component that was cached together with the essential
|
|
|
|
* query data. This can be either a result set (result caching)
|
|
|
|
* or an SQL query string (query caching).
|
|
|
|
*/
|
|
|
|
protected function _constructQueryFromCache($cached)
|
|
|
|
{
|
|
|
|
$cached = unserialize($cached);
|
|
|
|
$this->_tableAliasMap = $cached[2];
|
|
|
|
$customComponent = $cached[0];
|
|
|
|
|
|
|
|
$queryComponents = array();
|
|
|
|
$cachedComponents = $cached[1];
|
|
|
|
foreach ($cachedComponents as $alias => $components) {
|
|
|
|
$e = explode('.', $components[0]);
|
|
|
|
if (count($e) === 1) {
|
2008-01-05 22:55:56 +03:00
|
|
|
$queryComponents[$alias]['mapper'] = $this->_conn->getMapper($e[0]);
|
|
|
|
$queryComponents[$alias]['table'] = $queryComponents[$alias]['mapper']->getTable();
|
2007-11-25 18:57:08 +03:00
|
|
|
} else {
|
|
|
|
$queryComponents[$alias]['parent'] = $e[0];
|
|
|
|
$queryComponents[$alias]['relation'] = $queryComponents[$e[0]]['table']->getRelation($e[1]);
|
2008-01-05 22:55:56 +03:00
|
|
|
$queryComponents[$alias]['mapper'] = $this->_conn->getMapper($queryComponents[$alias]['relation']->getForeignComponentName());
|
|
|
|
$queryComponents[$alias]['table'] = $queryComponents[$alias]['mapper']->getTable();
|
2007-11-25 18:57:08 +03:00
|
|
|
}
|
|
|
|
if (isset($v[1])) {
|
|
|
|
$queryComponents[$alias]['agg'] = $components[1];
|
|
|
|
}
|
|
|
|
if (isset($v[2])) {
|
|
|
|
$queryComponents[$alias]['map'] = $components[2];
|
|
|
|
}
|
2007-11-20 17:26:42 +03:00
|
|
|
}
|
2007-11-25 18:57:08 +03:00
|
|
|
$this->_queryComponents = $queryComponents;
|
|
|
|
|
|
|
|
return $customComponent;
|
2007-11-20 17:26:42 +03:00
|
|
|
}
|
|
|
|
|
2007-11-21 17:29:59 +03:00
|
|
|
/**
|
|
|
|
* getCachedForm
|
|
|
|
* returns the cached form of this query for given resultSet
|
|
|
|
*
|
|
|
|
* @param array $resultSet
|
|
|
|
* @return string serialized string representation of this query
|
|
|
|
*/
|
2007-11-25 18:57:08 +03:00
|
|
|
public function getCachedForm($customComponent = null)
|
2007-11-21 17:29:59 +03:00
|
|
|
{
|
2007-11-25 18:57:08 +03:00
|
|
|
$componentInfo = array();
|
2007-11-21 17:29:59 +03:00
|
|
|
|
2007-11-25 18:57:08 +03:00
|
|
|
foreach ($this->getQueryComponents() as $alias => $components) {
|
|
|
|
if ( ! isset($components['parent'])) {
|
2008-01-05 22:55:56 +03:00
|
|
|
$componentInfo[$alias][] = $components['mapper']->getComponentName();
|
|
|
|
//$componentInfo[$alias][] = $components['mapper']->getComponentName();
|
2007-11-21 17:29:59 +03:00
|
|
|
} else {
|
2007-11-25 18:57:08 +03:00
|
|
|
$componentInfo[$alias][] = $components['parent'] . '.' . $components['relation']->getAlias();
|
2007-11-21 17:29:59 +03:00
|
|
|
}
|
2007-11-25 18:57:08 +03:00
|
|
|
if (isset($components['agg'])) {
|
|
|
|
$componentInfo[$alias][] = $components['agg'];
|
|
|
|
}
|
|
|
|
if (isset($components['map'])) {
|
|
|
|
$componentInfo[$alias][] = $components['map'];
|
2007-11-21 17:29:59 +03:00
|
|
|
}
|
|
|
|
}
|
2007-11-25 18:57:08 +03:00
|
|
|
|
|
|
|
return serialize(array($customComponent, $componentInfo, $this->getTableAliasMap()));
|
2007-11-21 17:29:59 +03:00
|
|
|
}
|
2007-11-20 17:26:42 +03:00
|
|
|
|
2007-07-24 15:34:00 +04:00
|
|
|
/**
|
|
|
|
* addSelect
|
|
|
|
* adds fields to the SELECT part of the query
|
|
|
|
*
|
|
|
|
* @param string $select Query SELECT part
|
|
|
|
* @return Doctrine_Query
|
|
|
|
*/
|
|
|
|
public function addSelect($select)
|
|
|
|
{
|
2007-11-24 21:11:09 +03:00
|
|
|
return $this->_addDqlQueryPart('select', $select, true);
|
2007-07-24 15:34:00 +04:00
|
|
|
}
|
2007-11-20 17:26:42 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* addTableAlias
|
|
|
|
* adds an alias for table and associates it with given component alias
|
|
|
|
*
|
|
|
|
* @param string $componentAlias the alias for the query component associated with given tableAlias
|
|
|
|
* @param string $tableAlias the table alias to be added
|
|
|
|
* @return Doctrine_Hydrate
|
2007-11-24 21:11:09 +03:00
|
|
|
* @deprecated
|
2007-11-20 17:26:42 +03:00
|
|
|
*/
|
|
|
|
public function addTableAlias($tableAlias, $componentAlias)
|
|
|
|
{
|
2007-11-24 21:11:09 +03:00
|
|
|
return $this->addSqlTableAlias($tableAlias, $componentAlias);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* addSqlTableAlias
|
|
|
|
* adds an SQL table alias and associates it a component alias
|
|
|
|
*
|
|
|
|
* @param string $componentAlias the alias for the query component associated with given tableAlias
|
|
|
|
* @param string $tableAlias the table alias to be added
|
|
|
|
* @return Doctrine_Query_Abstract
|
|
|
|
*/
|
|
|
|
public function addSqlTableAlias($sqlTableAlias, $componentAlias)
|
|
|
|
{
|
|
|
|
$this->_tableAliasMap[$sqlTableAlias] = $componentAlias;
|
2007-11-20 17:26:42 +03:00
|
|
|
return $this;
|
|
|
|
}
|
2007-10-21 10:23:59 +04:00
|
|
|
|
2007-07-24 15:34:00 +04:00
|
|
|
/**
|
|
|
|
* addFrom
|
|
|
|
* adds fields to the FROM part of the query
|
|
|
|
*
|
|
|
|
* @param string $from Query FROM part
|
|
|
|
* @return Doctrine_Query
|
|
|
|
*/
|
|
|
|
public function addFrom($from)
|
|
|
|
{
|
2007-11-24 21:11:09 +03:00
|
|
|
return $this->_addDqlQueryPart('from', $from, true);
|
2007-07-24 15:34:00 +04:00
|
|
|
}
|
2007-10-21 10:23:59 +04:00
|
|
|
|
2007-07-24 15:34:00 +04:00
|
|
|
/**
|
|
|
|
* addWhere
|
|
|
|
* adds conditions to the WHERE part of the query
|
|
|
|
*
|
|
|
|
* @param string $where Query WHERE part
|
|
|
|
* @param mixed $params an array of parameters or a simple scalar
|
|
|
|
* @return Doctrine_Query
|
|
|
|
*/
|
|
|
|
public function addWhere($where, $params = array())
|
|
|
|
{
|
|
|
|
if (is_array($params)) {
|
2007-09-02 13:28:38 +04:00
|
|
|
$this->_params['where'] = array_merge($this->_params['where'], $params);
|
2007-07-24 15:34:00 +04:00
|
|
|
} else {
|
2007-09-02 13:28:38 +04:00
|
|
|
$this->_params['where'][] = $params;
|
2007-07-24 15:34:00 +04:00
|
|
|
}
|
2007-11-24 21:11:09 +03:00
|
|
|
return $this->_addDqlQueryPart('where', $where, true);
|
2007-07-24 15:34:00 +04:00
|
|
|
}
|
2007-10-21 10:23:59 +04:00
|
|
|
|
2007-08-03 01:24:29 +04:00
|
|
|
/**
|
|
|
|
* whereIn
|
|
|
|
* adds IN condition to the query WHERE part
|
|
|
|
*
|
2007-11-10 18:46:01 +03:00
|
|
|
* @param string $expr the operand of the IN
|
2007-08-03 01:24:29 +04:00
|
|
|
* @param mixed $params an array of parameters or a simple scalar
|
2007-11-10 18:46:01 +03:00
|
|
|
* @param boolean $not whether or not to use NOT in front of IN
|
2007-08-03 01:24:29 +04:00
|
|
|
* @return Doctrine_Query
|
|
|
|
*/
|
2007-11-10 18:46:01 +03:00
|
|
|
public function whereIn($expr, $params = array(), $not = false)
|
2007-08-03 01:24:29 +04:00
|
|
|
{
|
2007-08-15 00:44:48 +04:00
|
|
|
$params = (array) $params;
|
2007-08-03 01:24:29 +04:00
|
|
|
$a = array();
|
|
|
|
foreach ($params as $k => $value) {
|
|
|
|
if ($value instanceof Doctrine_Expression) {
|
|
|
|
$value = $value->getSql();
|
2007-09-20 09:25:52 +04:00
|
|
|
unset($params[$k]);
|
2007-08-03 01:24:29 +04:00
|
|
|
} else {
|
2007-09-03 18:57:18 +04:00
|
|
|
$value = '?';
|
2007-08-03 01:24:29 +04:00
|
|
|
}
|
|
|
|
$a[] = $value;
|
|
|
|
}
|
2007-08-15 00:44:48 +04:00
|
|
|
|
2007-09-02 13:28:38 +04:00
|
|
|
$this->_params['where'] = array_merge($this->_params['where'], $params);
|
2007-08-15 00:44:48 +04:00
|
|
|
|
2007-11-10 18:46:01 +03:00
|
|
|
$where = $expr . ($not === true ? ' NOT ':'') . ' IN (' . implode(', ', $a) . ')';
|
2007-08-03 01:24:29 +04:00
|
|
|
|
2007-11-24 21:11:09 +03:00
|
|
|
return $this->_addDqlQueryPart('where', $where, true);
|
2007-08-03 01:24:29 +04:00
|
|
|
}
|
2007-10-21 10:23:59 +04:00
|
|
|
|
2007-11-18 15:37:46 +03:00
|
|
|
/**
|
|
|
|
* whereNotIn
|
|
|
|
* adds NOT IN condition to the query WHERE part
|
|
|
|
*
|
|
|
|
* @param string $expr the operand of the NOT IN
|
|
|
|
* @param mixed $params an array of parameters or a simple scalar
|
|
|
|
* @return Doctrine_Query
|
|
|
|
*/
|
|
|
|
public function whereNotIn($expr, $params = array())
|
|
|
|
{
|
|
|
|
return $this->whereIn($expr, $params, true);
|
|
|
|
}
|
|
|
|
|
2007-07-24 15:34:00 +04:00
|
|
|
/**
|
|
|
|
* addGroupBy
|
|
|
|
* adds fields to the GROUP BY part of the query
|
|
|
|
*
|
|
|
|
* @param string $groupby Query GROUP BY part
|
|
|
|
* @return Doctrine_Query
|
|
|
|
*/
|
|
|
|
public function addGroupBy($groupby)
|
|
|
|
{
|
2007-11-24 21:11:09 +03:00
|
|
|
return $this->_addDqlQueryPart('groupby', $groupby, true);
|
2007-07-24 15:34:00 +04:00
|
|
|
}
|
2007-10-21 10:23:59 +04:00
|
|
|
|
2007-07-24 15:34:00 +04:00
|
|
|
/**
|
|
|
|
* addHaving
|
|
|
|
* adds conditions to the HAVING part of the query
|
|
|
|
*
|
|
|
|
* @param string $having Query HAVING part
|
|
|
|
* @param mixed $params an array of parameters or a simple scalar
|
|
|
|
* @return Doctrine_Query
|
|
|
|
*/
|
|
|
|
public function addHaving($having, $params = array())
|
|
|
|
{
|
|
|
|
if (is_array($params)) {
|
2007-09-02 13:28:38 +04:00
|
|
|
$this->_params['having'] = array_merge($this->_params['having'], $params);
|
2007-07-24 15:34:00 +04:00
|
|
|
} else {
|
2007-09-02 13:28:38 +04:00
|
|
|
$this->_params['having'][] = $params;
|
2007-07-24 15:34:00 +04:00
|
|
|
}
|
2007-11-24 21:11:09 +03:00
|
|
|
return $this->_addDqlQueryPart('having', $having, true);
|
2007-07-24 15:34:00 +04:00
|
|
|
}
|
2007-10-21 10:23:59 +04:00
|
|
|
|
2007-07-24 15:34:00 +04:00
|
|
|
/**
|
|
|
|
* addOrderBy
|
|
|
|
* adds fields to the ORDER BY part of the query
|
|
|
|
*
|
|
|
|
* @param string $orderby Query ORDER BY part
|
|
|
|
* @return Doctrine_Query
|
|
|
|
*/
|
|
|
|
public function addOrderBy($orderby)
|
|
|
|
{
|
2007-11-24 21:11:09 +03:00
|
|
|
return $this->_addDqlQueryPart('orderby', $orderby, true);
|
2007-07-24 15:34:00 +04:00
|
|
|
}
|
2007-10-21 10:23:59 +04:00
|
|
|
|
2007-07-24 15:34:00 +04:00
|
|
|
/**
|
|
|
|
* select
|
|
|
|
* sets the SELECT part of the query
|
|
|
|
*
|
|
|
|
* @param string $select Query SELECT part
|
|
|
|
* @return Doctrine_Query
|
|
|
|
*/
|
|
|
|
public function select($select)
|
|
|
|
{
|
2007-11-24 21:11:09 +03:00
|
|
|
return $this->_addDqlQueryPart('select', $select);
|
2007-07-24 15:34:00 +04:00
|
|
|
}
|
2007-10-21 10:23:59 +04:00
|
|
|
|
2007-07-24 15:34:00 +04:00
|
|
|
/**
|
|
|
|
* distinct
|
|
|
|
* Makes the query SELECT DISTINCT.
|
|
|
|
*
|
|
|
|
* @param bool $flag Whether or not the SELECT is DISTINCT (default true).
|
|
|
|
* @return Doctrine_Query
|
|
|
|
*/
|
|
|
|
public function distinct($flag = true)
|
|
|
|
{
|
2007-11-24 21:11:09 +03:00
|
|
|
$this->_sqlParts['distinct'] = (bool) $flag;
|
2007-07-24 15:34:00 +04:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* forUpdate
|
|
|
|
* Makes the query SELECT FOR UPDATE.
|
|
|
|
*
|
|
|
|
* @param bool $flag Whether or not the SELECT is FOR UPDATE (default true).
|
|
|
|
* @return Doctrine_Query
|
|
|
|
*/
|
|
|
|
public function forUpdate($flag = true)
|
|
|
|
{
|
2007-11-24 21:11:09 +03:00
|
|
|
$this->_sqlParts[self::FOR_UPDATE] = (bool) $flag;
|
2007-07-24 15:34:00 +04:00
|
|
|
return $this;
|
|
|
|
}
|
2007-10-21 10:23:59 +04:00
|
|
|
|
2007-07-24 15:34:00 +04:00
|
|
|
/**
|
|
|
|
* delete
|
|
|
|
* sets the query type to DELETE
|
|
|
|
*
|
|
|
|
* @return Doctrine_Query
|
|
|
|
*/
|
|
|
|
public function delete()
|
|
|
|
{
|
2007-11-24 21:11:09 +03:00
|
|
|
$this->_type = self::DELETE;
|
2007-07-24 15:34:00 +04:00
|
|
|
return $this;
|
|
|
|
}
|
2007-10-21 10:23:59 +04:00
|
|
|
|
2007-07-24 15:34:00 +04:00
|
|
|
/**
|
|
|
|
* update
|
|
|
|
* sets the UPDATE part of the query
|
|
|
|
*
|
|
|
|
* @param string $update Query UPDATE part
|
|
|
|
* @return Doctrine_Query
|
|
|
|
*/
|
|
|
|
public function update($update)
|
|
|
|
{
|
2007-11-24 21:11:09 +03:00
|
|
|
$this->_type = self::UPDATE;
|
|
|
|
return $this->_addDqlQueryPart('from', $update);
|
2007-07-24 15:34:00 +04:00
|
|
|
}
|
2007-10-21 10:23:59 +04:00
|
|
|
|
2007-07-24 15:34:00 +04:00
|
|
|
/**
|
|
|
|
* set
|
|
|
|
* sets the SET part of the query
|
|
|
|
*
|
|
|
|
* @param string $update Query UPDATE part
|
|
|
|
* @return Doctrine_Query
|
|
|
|
*/
|
|
|
|
public function set($key, $value, $params = null)
|
|
|
|
{
|
2007-09-03 18:57:18 +04:00
|
|
|
if (is_array($key)) {
|
2007-08-15 00:23:02 +04:00
|
|
|
foreach ($key as $k => $v) {
|
2007-09-03 18:57:18 +04:00
|
|
|
$this->set($k, '?', array($v));
|
2007-08-15 00:23:02 +04:00
|
|
|
}
|
2007-10-04 19:06:46 +04:00
|
|
|
return $this;
|
2007-09-03 18:57:18 +04:00
|
|
|
} else {
|
2007-08-15 00:23:02 +04:00
|
|
|
if ($params !== null) {
|
|
|
|
if (is_array($params)) {
|
2007-09-02 13:28:38 +04:00
|
|
|
$this->_params['set'] = array_merge($this->_params['set'], $params);
|
2007-08-15 00:23:02 +04:00
|
|
|
} else {
|
2007-09-02 13:28:38 +04:00
|
|
|
$this->_params['set'][] = $params;
|
2007-08-15 00:23:02 +04:00
|
|
|
}
|
2007-07-24 15:34:00 +04:00
|
|
|
}
|
2007-11-24 21:11:09 +03:00
|
|
|
return $this->_addDqlQueryPart('set', $key . ' = ' . $value, true);
|
2007-07-24 15:34:00 +04:00
|
|
|
}
|
|
|
|
}
|
2007-10-21 10:23:59 +04:00
|
|
|
|
2007-07-24 15:34:00 +04:00
|
|
|
/**
|
|
|
|
* from
|
|
|
|
* sets the FROM part of the query
|
|
|
|
*
|
|
|
|
* @param string $from Query FROM part
|
|
|
|
* @return Doctrine_Query
|
|
|
|
*/
|
|
|
|
public function from($from)
|
|
|
|
{
|
2007-11-24 21:11:09 +03:00
|
|
|
return $this->_addDqlQueryPart('from', $from);
|
2007-07-24 15:34:00 +04:00
|
|
|
}
|
2007-10-21 10:23:59 +04:00
|
|
|
|
2007-07-24 15:34:00 +04:00
|
|
|
/**
|
|
|
|
* innerJoin
|
|
|
|
* appends an INNER JOIN to the FROM part of the query
|
|
|
|
*
|
|
|
|
* @param string $join Query INNER JOIN
|
|
|
|
* @return Doctrine_Query
|
|
|
|
*/
|
2007-12-26 23:52:37 +03:00
|
|
|
public function innerJoin($join, $params = array())
|
2007-07-24 15:34:00 +04:00
|
|
|
{
|
2007-12-26 23:52:37 +03:00
|
|
|
if (is_array($params)) {
|
|
|
|
$this->_params['join'] = array_merge($this->_params['join'], $params);
|
|
|
|
} else {
|
|
|
|
$this->_params['join'][] = $params;
|
|
|
|
}
|
|
|
|
|
2007-11-24 21:11:09 +03:00
|
|
|
return $this->_addDqlQueryPart('from', 'INNER JOIN ' . $join, true);
|
2007-07-24 15:34:00 +04:00
|
|
|
}
|
2007-10-21 10:23:59 +04:00
|
|
|
|
2007-07-24 15:34:00 +04:00
|
|
|
/**
|
|
|
|
* leftJoin
|
|
|
|
* appends a LEFT JOIN to the FROM part of the query
|
|
|
|
*
|
|
|
|
* @param string $join Query LEFT JOIN
|
|
|
|
* @return Doctrine_Query
|
|
|
|
*/
|
2007-12-26 23:52:37 +03:00
|
|
|
public function leftJoin($join, $params = array())
|
2007-07-24 15:34:00 +04:00
|
|
|
{
|
2007-12-26 23:52:37 +03:00
|
|
|
if (is_array($params)) {
|
|
|
|
$this->_params['join'] = array_merge($this->_params['join'], $params);
|
|
|
|
} else {
|
|
|
|
$this->_params['join'][] = $params;
|
|
|
|
}
|
|
|
|
|
2007-11-24 21:11:09 +03:00
|
|
|
return $this->_addDqlQueryPart('from', 'LEFT JOIN ' . $join, true);
|
2007-07-24 15:34:00 +04:00
|
|
|
}
|
2007-10-21 10:23:59 +04:00
|
|
|
|
2007-07-24 15:34:00 +04:00
|
|
|
/**
|
|
|
|
* groupBy
|
|
|
|
* sets the GROUP BY part of the query
|
|
|
|
*
|
|
|
|
* @param string $groupby Query GROUP BY part
|
|
|
|
* @return Doctrine_Query
|
|
|
|
*/
|
|
|
|
public function groupBy($groupby)
|
|
|
|
{
|
2007-11-24 21:11:09 +03:00
|
|
|
return $this->_addDqlQueryPart('groupby', $groupby);
|
2007-07-24 15:34:00 +04:00
|
|
|
}
|
2007-10-21 10:23:59 +04:00
|
|
|
|
2007-07-24 15:34:00 +04:00
|
|
|
/**
|
|
|
|
* where
|
|
|
|
* sets the WHERE part of the query
|
|
|
|
*
|
|
|
|
* @param string $join Query WHERE part
|
|
|
|
* @param mixed $params an array of parameters or a simple scalar
|
|
|
|
* @return Doctrine_Query
|
|
|
|
*/
|
|
|
|
public function where($where, $params = array())
|
|
|
|
{
|
2007-09-02 13:28:38 +04:00
|
|
|
$this->_params['where'] = array();
|
2007-07-24 15:34:00 +04:00
|
|
|
if (is_array($params)) {
|
2007-09-02 13:28:38 +04:00
|
|
|
$this->_params['where'] = $params;
|
2007-07-24 15:34:00 +04:00
|
|
|
} else {
|
2007-09-02 13:28:38 +04:00
|
|
|
$this->_params['where'][] = $params;
|
2007-07-24 15:34:00 +04:00
|
|
|
}
|
|
|
|
|
2007-11-24 21:11:09 +03:00
|
|
|
return $this->_addDqlQueryPart('where', $where);
|
2007-07-24 15:34:00 +04:00
|
|
|
}
|
2007-10-21 10:23:59 +04:00
|
|
|
|
2007-07-24 15:34:00 +04:00
|
|
|
/**
|
|
|
|
* having
|
|
|
|
* sets the HAVING part of the query
|
|
|
|
*
|
|
|
|
* @param string $having Query HAVING part
|
|
|
|
* @param mixed $params an array of parameters or a simple scalar
|
|
|
|
* @return Doctrine_Query
|
|
|
|
*/
|
|
|
|
public function having($having, $params = array())
|
|
|
|
{
|
2007-09-02 13:28:38 +04:00
|
|
|
$this->_params['having'] = array();
|
2007-07-24 15:34:00 +04:00
|
|
|
if (is_array($params)) {
|
2007-09-02 13:28:38 +04:00
|
|
|
$this->_params['having'] = $params;
|
2007-07-24 15:34:00 +04:00
|
|
|
} else {
|
2007-09-02 13:28:38 +04:00
|
|
|
$this->_params['having'][] = $params;
|
2007-07-24 15:34:00 +04:00
|
|
|
}
|
|
|
|
|
2007-11-24 21:11:09 +03:00
|
|
|
return $this->_addDqlQueryPart('having', $having);
|
2007-07-24 15:34:00 +04:00
|
|
|
}
|
2007-10-21 10:23:59 +04:00
|
|
|
|
2007-07-24 15:34:00 +04:00
|
|
|
/**
|
|
|
|
* orderBy
|
|
|
|
* sets the ORDER BY part of the query
|
|
|
|
*
|
|
|
|
* @param string $orderby Query ORDER BY part
|
|
|
|
* @return Doctrine_Query
|
|
|
|
*/
|
|
|
|
public function orderBy($orderby)
|
|
|
|
{
|
2007-11-24 21:11:09 +03:00
|
|
|
return $this->_addDqlQueryPart('orderby', $orderby);
|
2007-07-24 15:34:00 +04:00
|
|
|
}
|
2007-10-21 10:23:59 +04:00
|
|
|
|
2007-07-24 15:34:00 +04:00
|
|
|
/**
|
|
|
|
* limit
|
|
|
|
* sets the Query query limit
|
|
|
|
*
|
|
|
|
* @param integer $limit limit to be used for limiting the query results
|
|
|
|
* @return Doctrine_Query
|
|
|
|
*/
|
|
|
|
public function limit($limit)
|
|
|
|
{
|
2007-11-24 21:11:09 +03:00
|
|
|
return $this->_addDqlQueryPart('limit', $limit);
|
2007-07-24 15:34:00 +04:00
|
|
|
}
|
2007-10-21 10:23:59 +04:00
|
|
|
|
2007-07-24 15:34:00 +04:00
|
|
|
/**
|
|
|
|
* offset
|
|
|
|
* sets the Query query offset
|
|
|
|
*
|
|
|
|
* @param integer $offset offset to be used for paginating the query
|
|
|
|
* @return Doctrine_Query
|
|
|
|
*/
|
|
|
|
public function offset($offset)
|
|
|
|
{
|
2007-11-24 21:11:09 +03:00
|
|
|
return $this->_addDqlQueryPart('offset', $offset);
|
2007-07-24 15:34:00 +04:00
|
|
|
}
|
2007-11-20 17:26:42 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* getSql
|
2007-11-24 21:11:09 +03:00
|
|
|
* shortcut for {@link getSqlQuery()}.
|
2007-11-20 17:26:42 +03:00
|
|
|
*
|
|
|
|
* @return string sql query string
|
|
|
|
*/
|
|
|
|
public function getSql()
|
|
|
|
{
|
2007-11-24 21:11:09 +03:00
|
|
|
return $this->getSqlQuery();
|
2007-11-20 17:26:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clear
|
|
|
|
* resets all the variables
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
protected function clear()
|
|
|
|
{
|
2007-11-24 21:11:09 +03:00
|
|
|
$this->_sqlParts = array(
|
2007-11-20 17:26:42 +03:00
|
|
|
'select' => array(),
|
|
|
|
'distinct' => false,
|
|
|
|
'forUpdate' => false,
|
|
|
|
'from' => array(),
|
|
|
|
'set' => array(),
|
|
|
|
'join' => array(),
|
|
|
|
'where' => array(),
|
|
|
|
'groupby' => array(),
|
|
|
|
'having' => array(),
|
|
|
|
'orderby' => array(),
|
|
|
|
'limit' => false,
|
|
|
|
'offset' => false,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setHydrationMode($hydrationMode)
|
|
|
|
{
|
|
|
|
$this->_hydrator->setHydrationMode($hydrationMode);
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2007-11-24 21:11:09 +03:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
*/
|
2007-11-20 17:26:42 +03:00
|
|
|
public function getAliasMap()
|
|
|
|
{
|
2007-11-24 21:11:09 +03:00
|
|
|
return $this->_queryComponents;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the components of this query.
|
|
|
|
*/
|
|
|
|
public function getQueryComponents()
|
|
|
|
{
|
|
|
|
return $this->_queryComponents;
|
2007-11-20 17:26:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the SQL parts.
|
|
|
|
*
|
|
|
|
* @return array The parts
|
2007-11-24 21:11:09 +03:00
|
|
|
* @deprecated
|
2007-11-20 17:26:42 +03:00
|
|
|
*/
|
|
|
|
public function getParts()
|
|
|
|
{
|
2007-11-24 21:11:09 +03:00
|
|
|
return $this->getSqlParts();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the SQL parts.
|
|
|
|
*
|
|
|
|
* @return array The parts
|
|
|
|
*/
|
|
|
|
public function getSqlParts()
|
|
|
|
{
|
|
|
|
return $this->_sqlParts;
|
2007-11-20 17:26:42 +03:00
|
|
|
}
|
2008-01-07 16:48:08 +03:00
|
|
|
|
2007-11-20 17:26:42 +03:00
|
|
|
/**
|
|
|
|
* getType
|
|
|
|
*
|
|
|
|
* returns the type of this query object
|
2007-11-24 21:11:09 +03:00
|
|
|
* by default the type is Doctrine_Query_Abstract::SELECT but if update() or delete()
|
|
|
|
* are being called the type is Doctrine_Query_Abstract::UPDATE and Doctrine_Query_Abstract::DELETE,
|
2007-11-20 17:26:42 +03:00
|
|
|
* respectively
|
|
|
|
*
|
2007-11-24 21:11:09 +03:00
|
|
|
* @see Doctrine_Query_Abstract::SELECT
|
|
|
|
* @see Doctrine_Query_Abstract::UPDATE
|
|
|
|
* @see Doctrine_Query_Abstract::DELETE
|
2007-11-20 17:26:42 +03:00
|
|
|
*
|
|
|
|
* @return integer return the query type
|
|
|
|
*/
|
|
|
|
public function getType()
|
|
|
|
{
|
2007-11-24 21:11:09 +03:00
|
|
|
return $this->_type;
|
2007-11-20 17:26:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* useCache
|
|
|
|
*
|
|
|
|
* @param Doctrine_Cache_Interface|bool $driver cache driver
|
|
|
|
* @param integer $timeToLive how long the cache entry is valid
|
|
|
|
* @return Doctrine_Hydrate this object
|
2007-11-24 21:11:09 +03:00
|
|
|
* @deprecated Use useResultCache()
|
2007-11-20 17:26:42 +03:00
|
|
|
*/
|
|
|
|
public function useCache($driver = true, $timeToLive = null)
|
2007-11-24 21:11:09 +03:00
|
|
|
{
|
|
|
|
return $this->useResultCache($driver, $timeToLive);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* useResultCache
|
|
|
|
*
|
|
|
|
* @param Doctrine_Cache_Interface|bool $driver cache driver
|
|
|
|
* @param integer $timeToLive how long the cache entry is valid
|
|
|
|
* @return Doctrine_Hydrate this object
|
|
|
|
*/
|
|
|
|
public function useResultCache($driver = true, $timeToLive = null)
|
2007-11-20 17:26:42 +03:00
|
|
|
{
|
2007-11-25 18:57:08 +03:00
|
|
|
if ($driver !== null && $driver !== true && ! ($driver instanceOf Doctrine_Cache_Interface)){
|
2007-11-20 17:26:42 +03:00
|
|
|
$msg = 'First argument should be instance of Doctrine_Cache_Interface or null.';
|
2007-11-24 21:11:09 +03:00
|
|
|
throw new Doctrine_Query_Exception($msg);
|
2007-11-20 17:26:42 +03:00
|
|
|
}
|
2007-11-24 21:11:09 +03:00
|
|
|
$this->_resultCache = $driver;
|
2007-11-20 17:26:42 +03:00
|
|
|
|
2007-11-24 21:11:09 +03:00
|
|
|
return $this->setResultCacheLifeSpan($timeToLive);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* useQueryCache
|
|
|
|
*
|
|
|
|
* @param Doctrine_Cache_Interface|bool $driver cache driver
|
|
|
|
* @param integer $timeToLive how long the cache entry is valid
|
|
|
|
* @return Doctrine_Hydrate this object
|
|
|
|
*/
|
2007-11-25 22:07:30 +03:00
|
|
|
public function useQueryCache(Doctrine_Cache_Interface $driver, $timeToLive = null)
|
2007-11-24 21:11:09 +03:00
|
|
|
{
|
2007-11-25 18:57:08 +03:00
|
|
|
$this->_queryCache = $driver;
|
|
|
|
return $this->setQueryCacheLifeSpan($timeToLive);
|
2007-11-20 17:26:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* expireCache
|
|
|
|
*
|
|
|
|
* @param boolean $expire whether or not to force cache expiration
|
|
|
|
* @return Doctrine_Hydrate this object
|
2007-11-24 21:11:09 +03:00
|
|
|
* @deprecated Use expireResultCache()
|
2007-11-20 17:26:42 +03:00
|
|
|
*/
|
|
|
|
public function expireCache($expire = true)
|
|
|
|
{
|
2007-11-24 21:11:09 +03:00
|
|
|
return $this->expireResultCache($expire);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* expireCache
|
|
|
|
*
|
|
|
|
* @param boolean $expire whether or not to force cache expiration
|
|
|
|
* @return Doctrine_Hydrate this object
|
|
|
|
*/
|
|
|
|
public function expireResultCache($expire = true)
|
|
|
|
{
|
|
|
|
$this->_expireResultCache = true;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* expireQueryCache
|
|
|
|
*
|
|
|
|
* @param boolean $expire whether or not to force cache expiration
|
|
|
|
* @return Doctrine_Hydrate this object
|
|
|
|
*/
|
|
|
|
public function expireQueryCache($expire = true)
|
|
|
|
{
|
|
|
|
$this->_expireQueryCache = true;
|
2007-11-20 17:26:42 +03:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* setCacheLifeSpan
|
|
|
|
*
|
|
|
|
* @param integer $timeToLive how long the cache entry is valid
|
|
|
|
* @return Doctrine_Hydrate this object
|
2007-11-24 21:11:09 +03:00
|
|
|
* @deprecated Use setResultCacheLifeSpan()
|
2007-11-20 17:26:42 +03:00
|
|
|
*/
|
|
|
|
public function setCacheLifeSpan($timeToLive)
|
2007-11-24 21:11:09 +03:00
|
|
|
{
|
|
|
|
return $this->setResultCacheLifeSpan($timeToLive);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* setResultCacheLifeSpan
|
|
|
|
*
|
|
|
|
* @param integer $timeToLive how long the cache entry is valid
|
|
|
|
* @return Doctrine_Hydrate this object
|
|
|
|
*/
|
|
|
|
public function setResultCacheLifeSpan($timeToLive)
|
2007-11-20 17:26:42 +03:00
|
|
|
{
|
|
|
|
if ($timeToLive !== null) {
|
|
|
|
$timeToLive = (int) $timeToLive;
|
|
|
|
}
|
2007-11-24 21:11:09 +03:00
|
|
|
$this->_resultCacheTTL = $timeToLive;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* setQueryCacheLifeSpan
|
|
|
|
*
|
|
|
|
* @param integer $timeToLive how long the cache entry is valid
|
|
|
|
* @return Doctrine_Hydrate this object
|
|
|
|
*/
|
|
|
|
public function setQueryCacheLifeSpan($timeToLive)
|
|
|
|
{
|
|
|
|
if ($timeToLive !== null) {
|
|
|
|
$timeToLive = (int) $timeToLive;
|
|
|
|
}
|
|
|
|
$this->_queryCacheTTL = $timeToLive;
|
2007-11-20 17:26:42 +03:00
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* getCacheDriver
|
|
|
|
* returns the cache driver associated with this object
|
|
|
|
*
|
|
|
|
* @return Doctrine_Cache_Interface|boolean|null cache driver
|
2007-11-24 21:11:09 +03:00
|
|
|
* @deprecated Use getResultCacheDriver()
|
2007-11-20 17:26:42 +03:00
|
|
|
*/
|
|
|
|
public function getCacheDriver()
|
|
|
|
{
|
2007-11-24 21:11:09 +03:00
|
|
|
return $this->getResultCacheDriver();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* getResultCacheDriver
|
|
|
|
* returns the cache driver used for caching result sets
|
|
|
|
*
|
|
|
|
* @return Doctrine_Cache_Interface|boolean|null cache driver
|
|
|
|
*/
|
|
|
|
public function getResultCacheDriver()
|
|
|
|
{
|
|
|
|
if ($this->_resultCache instanceof Doctrine_Cache_Interface) {
|
|
|
|
return $this->_resultCache;
|
2007-11-20 17:26:42 +03:00
|
|
|
} else {
|
2007-11-24 21:11:09 +03:00
|
|
|
return $this->_conn->getResultCacheDriver();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* getQueryCacheDriver
|
|
|
|
* returns the cache driver used for caching queries
|
|
|
|
*
|
|
|
|
* @return Doctrine_Cache_Interface|boolean|null cache driver
|
|
|
|
*/
|
|
|
|
public function getQueryCacheDriver()
|
|
|
|
{
|
|
|
|
if ($this->_queryCache instanceof Doctrine_Cache_Interface) {
|
|
|
|
return $this->_queryCache;
|
|
|
|
} else {
|
|
|
|
return $this->_conn->getQueryCacheDriver();
|
2007-11-20 17:26:42 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* getConnection
|
|
|
|
*
|
|
|
|
* @return Doctrine_Connection
|
|
|
|
*/
|
|
|
|
public function getConnection()
|
|
|
|
{
|
|
|
|
return $this->_conn;
|
|
|
|
}
|
2007-11-24 21:11:09 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds a DQL part to the internal parts collection.
|
|
|
|
*
|
|
|
|
* @param string $queryPartName The name of the query part.
|
|
|
|
* @param string $queryPart The actual query part to add.
|
|
|
|
* @param boolean $append Whether to append $queryPart to already existing
|
|
|
|
* parts under the same $queryPartName. Defaults to FALSE
|
|
|
|
* (previously added parts with the same name get overridden).
|
|
|
|
*/
|
|
|
|
protected function _addDqlQueryPart($queryPartName, $queryPart, $append = false)
|
|
|
|
{
|
|
|
|
if ($append) {
|
|
|
|
$this->_dqlParts[$queryPartName][] = $queryPart;
|
|
|
|
} else {
|
|
|
|
$this->_dqlParts[$queryPartName] = array($queryPart);
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->_state = Doctrine_Query::STATE_DIRTY;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2007-07-24 15:34:00 +04:00
|
|
|
/**
|
2007-11-24 21:11:09 +03:00
|
|
|
* _processDqlQueryPart
|
|
|
|
* parses given query part
|
2007-07-24 15:34:00 +04:00
|
|
|
*
|
|
|
|
* @param string $queryPartName the name of the query part
|
2007-11-24 21:11:09 +03:00
|
|
|
* @param array $queryParts an array containing the query part data
|
2007-07-24 15:34:00 +04:00
|
|
|
* @return Doctrine_Query this object
|
2007-11-24 21:11:09 +03:00
|
|
|
* @todo Better description. "parses given query part" ??? Then wheres the difference
|
|
|
|
* between process/parseQueryPart? I suppose this does something different.
|
2007-07-24 15:34:00 +04:00
|
|
|
*/
|
2007-11-24 21:11:09 +03:00
|
|
|
protected function _processDqlQueryPart($queryPartName, $queryParts)
|
|
|
|
{
|
|
|
|
$this->removeSqlQueryPart($queryPartName);
|
|
|
|
|
|
|
|
if (is_array($queryParts) && ! empty($queryParts)) {
|
|
|
|
foreach ($queryParts as $queryPart) {
|
|
|
|
$parser = $this->_getParser($queryPartName);
|
|
|
|
$sql = $parser->parse($queryPart);
|
|
|
|
if (isset($sql)) {
|
|
|
|
if ($queryPartName == 'limit' || $queryPartName == 'offset') {
|
|
|
|
$this->setSqlQueryPart($queryPartName, $sql);
|
|
|
|
} else {
|
|
|
|
$this->addSqlQueryPart($queryPartName, $sql);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* _getParser
|
|
|
|
* parser lazy-loader
|
|
|
|
*
|
|
|
|
* @throws Doctrine_Query_Exception if unknown parser name given
|
|
|
|
* @return Doctrine_Query_Part
|
|
|
|
* @todo Doc/Description: What is the parameter for? Which parsers are available?
|
|
|
|
*/
|
|
|
|
protected function _getParser($name)
|
|
|
|
{
|
|
|
|
if ( ! isset($this->_parsers[$name])) {
|
|
|
|
$class = 'Doctrine_Query_' . ucwords(strtolower($name));
|
|
|
|
|
|
|
|
Doctrine::autoload($class);
|
|
|
|
|
|
|
|
if ( ! class_exists($class)) {
|
|
|
|
throw new Doctrine_Query_Exception('Unknown parser ' . $name);
|
|
|
|
}
|
|
|
|
|
2007-11-24 21:58:33 +03:00
|
|
|
$this->_parsers[$name] = new $class($this, $this->_tokenizer);
|
2007-11-24 21:11:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return $this->_parsers[$name];
|
|
|
|
}
|
2007-11-20 17:26:42 +03:00
|
|
|
|
|
|
|
/**
|
2007-11-24 21:11:09 +03:00
|
|
|
* Gets the SQL query that corresponds to this query object.
|
|
|
|
* The returned SQL syntax depends on the connection driver that is used
|
|
|
|
* by this query object at the time of this method call.
|
2007-11-20 17:26:42 +03:00
|
|
|
*
|
2007-11-24 21:11:09 +03:00
|
|
|
* @param array $params
|
|
|
|
*/
|
|
|
|
abstract public function getSqlQuery($params = array());
|
|
|
|
|
|
|
|
/**
|
|
|
|
* parseDqlQuery
|
|
|
|
* parses a dql query
|
2007-11-20 17:26:42 +03:00
|
|
|
*
|
2007-11-24 21:11:09 +03:00
|
|
|
* @param string $query query to be parsed
|
|
|
|
* @return Doctrine_Query_Abstract this object
|
2007-11-20 17:26:42 +03:00
|
|
|
*/
|
2007-11-24 21:11:09 +03:00
|
|
|
abstract public function parseDqlQuery($query);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
*/
|
|
|
|
public function parseQuery($query)
|
|
|
|
{
|
|
|
|
return $this->parseDqlQuery($query);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
*/
|
|
|
|
public function getQuery($params = array())
|
|
|
|
{
|
|
|
|
return $this->getSqlQuery($params);
|
|
|
|
}
|
2007-11-10 18:46:01 +03:00
|
|
|
}
|