Commit a0dd44ad authored by zYne's avatar zYne

--no commit message

--no commit message
parent c5d08909
...@@ -112,10 +112,11 @@ class Doctrine_Export_Mysql extends Doctrine_Export ...@@ -112,10 +112,11 @@ class Doctrine_Export_Mysql extends Doctrine_Export
} }
if ( ! $found) { if ( ! $found) {
$options['indexes'] = array($local => array('fields' => array($local => array()))); $options['indexes'] = array_merge($options['indexes'], array($local => array('fields' => array($local => array()))));
} }
} }
} }
// add all indexes // add all indexes
if (isset($options['indexes']) && ! empty($options['indexes'])) { if (isset($options['indexes']) && ! empty($options['indexes'])) {
foreach($options['indexes'] as $index => $definition) { foreach($options['indexes'] as $index => $definition) {
...@@ -146,7 +147,7 @@ class Doctrine_Export_Mysql extends Doctrine_Export ...@@ -146,7 +147,7 @@ class Doctrine_Export_Mysql extends Doctrine_Export
$type = false; $type = false;
// get the type of the table // get the type of the table
if ( ! empty($options['type'])) { if (isset($options['type'])) {
$type = $options['type']; $type = $options['type'];
} else { } else {
$type = $this->conn->getAttribute(Doctrine::ATTR_DEFAULT_TABLE_TYPE); $type = $this->conn->getAttribute(Doctrine::ATTR_DEFAULT_TABLE_TYPE);
......
...@@ -32,6 +32,15 @@ Doctrine::autoload('Doctrine_Query_Abstract'); ...@@ -32,6 +32,15 @@ Doctrine::autoload('Doctrine_Query_Abstract');
*/ */
class Doctrine_Query extends Doctrine_Query_Abstract implements Countable class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
{ {
const STATE_CLEAN = 1;
const STATE_DIRTY = 2;
const STATE_DIRECT = 3;
const STATE_LOCKED = 4;
protected $subqueryAliases = array(); protected $subqueryAliases = array();
/** /**
* @param boolean $needsSubquery * @param boolean $needsSubquery
...@@ -87,6 +96,8 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable ...@@ -87,6 +96,8 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
*/ */
protected $_pendingJoinConditions = array(); protected $_pendingJoinConditions = array();
protected $_state = Doctrine_Query::STATE_CLEAN;
/** /**
* create * create
* returns a new Doctrine_Query object * returns a new Doctrine_Query object
...@@ -263,6 +274,10 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable ...@@ -263,6 +274,10 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
*/ */
public function parseQueryPart($queryPartName, $queryPart, $append = false) public function parseQueryPart($queryPartName, $queryPart, $append = false)
{ {
if ($this->_state === self::STATE_LOCKED) {
throw new Doctrine_Query_Exception('This query object is locked. No query parts can be manipulated.');
}
// sanity check // sanity check
if ($queryPart === '' || $queryPart === null) { if ($queryPart === '' || $queryPart === null) {
...@@ -276,6 +291,19 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable ...@@ -276,6 +291,19 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
$this->_dqlParts[$queryPartName] = array($queryPart); $this->_dqlParts[$queryPartName] = array($queryPart);
} }
if ($this->_state === self::STATE_DIRECT) {
$parser = $this->getParser($queryPartName);
$sql = $parser->parse($queryPart);
if (isset($sql)) {
if ($append) {
$this->addQueryPart($queryPartName, $sql);
} else {
$this->setQueryPart($queryPartName, $sql);
}
}
}
return $this; return $this;
} }
...@@ -623,6 +651,19 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable ...@@ -623,6 +651,19 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
$this->parts['from'][$k] = $part; $this->parts['from'][$k] = $part;
} }
return $q; return $q;
}
/**
* preQuery
*
* Empty template method to provide Query subclasses with the possibility
* to hook into the query building procedure, doing any custom / specialized
* query building procedures that are neccessary.
*
* @return void
*/
public function preQuery()
{
} }
/** /**
* builds the sql query from the given parameters and applies things such as * builds the sql query from the given parameters and applies things such as
...@@ -634,14 +675,16 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable ...@@ -634,14 +675,16 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
*/ */
public function getQuery($params = array()) public function getQuery($params = array())
{ {
// check if parser cache is on $parts = $this->_dqlParts;
// reset the state
$this->_aliasMap = array(); $this->_aliasMap = array();
$this->pendingAggregates = array(); $this->pendingAggregates = array();
$this->aggregateMap = array(); $this->aggregateMap = array();
$this->reset(); $this->reset();
// parse the DQL parts
foreach ($this->_dqlParts as $queryPartName => $queryParts) { foreach ($this->_dqlParts as $queryPartName => $queryParts) {
$this->parts[$queryPartName] = array(); $this->parts[$queryPartName] = array();
if (is_array($queryParts) && ! empty($queryParts)) { if (is_array($queryParts) && ! empty($queryParts)) {
...@@ -664,6 +707,13 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable ...@@ -664,6 +707,13 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable
} }
} }
} }
$this->_state = self::STATE_DIRECT;
// invoke the preQuery hook
$this->preQuery();
$this->_state = self::STATE_CLEAN;
$this->_dqlParts = $parts;
if (empty($this->parts['from'])) { if (empty($this->parts['from'])) {
return false; return false;
......
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