More refactorings. Commented out the plugin tests for now. They seem to wreak havoc with a lot of other tests (especially validator tests) and i havent found the reason yet.
This commit is contained in:
parent
24a8cef0e6
commit
78f5a2edcb
@ -238,20 +238,6 @@ abstract class Doctrine_Configurable extends Doctrine_Locator_Injectable
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* getCacheDriver
|
|
||||||
*
|
|
||||||
* @return Doctrine_Cache_Interface
|
|
||||||
*/
|
|
||||||
public function getCacheDriver()
|
|
||||||
{
|
|
||||||
if ( ! isset($this->attributes[Doctrine::ATTR_CACHE])) {
|
|
||||||
throw new Doctrine_Exception('Cache driver not initialized.');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->attributes[Doctrine::ATTR_CACHE];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Doctrine_EventListener $listener
|
* @param Doctrine_EventListener $listener
|
||||||
* @return void
|
* @return void
|
||||||
|
@ -914,17 +914,15 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
|||||||
$this->getAttribute(Doctrine::ATTR_LISTENER)->preQuery($event);
|
$this->getAttribute(Doctrine::ATTR_LISTENER)->preQuery($event);
|
||||||
|
|
||||||
if ( ! $event->skipOperation) {
|
if ( ! $event->skipOperation) {
|
||||||
//echo $query . "<br />";
|
|
||||||
$stmt = $this->dbh->query($query);
|
$stmt = $this->dbh->query($query);
|
||||||
|
|
||||||
$this->_count++;
|
$this->_count++;
|
||||||
}
|
}
|
||||||
$this->getAttribute(Doctrine::ATTR_LISTENER)->postQuery($event);
|
$this->getAttribute(Doctrine::ATTR_LISTENER)->postQuery($event);
|
||||||
|
|
||||||
return $stmt;
|
return $stmt;
|
||||||
}
|
}
|
||||||
} catch(Doctrine_Adapter_Exception $e) {
|
} catch (Doctrine_Adapter_Exception $e) {
|
||||||
} catch(PDOException $e) { }
|
} catch (PDOException $e) { }
|
||||||
|
|
||||||
$this->rethrowException($e, $this);
|
$this->rethrowException($e, $this);
|
||||||
}
|
}
|
||||||
@ -959,8 +957,8 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
|||||||
|
|
||||||
return $count;
|
return $count;
|
||||||
}
|
}
|
||||||
} catch(Doctrine_Adapter_Exception $e) {
|
} catch (Doctrine_Adapter_Exception $e) {
|
||||||
} catch(PDOException $e) { }
|
} catch (PDOException $e) { }
|
||||||
|
|
||||||
$this->rethrowException($e, $this);
|
$this->rethrowException($e, $this);
|
||||||
}
|
}
|
||||||
@ -1202,6 +1200,31 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
|||||||
return $this->dbh->errorInfo();
|
return $this->dbh->errorInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* getCacheDriver
|
||||||
|
*
|
||||||
|
* @return Doctrine_Cache_Interface
|
||||||
|
* @deprecated Use getResultCacheDriver()
|
||||||
|
*/
|
||||||
|
public function getCacheDriver()
|
||||||
|
{
|
||||||
|
return $this->getResultCacheDriver();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* getResultCacheDriver
|
||||||
|
*
|
||||||
|
* @return Doctrine_Cache_Interface
|
||||||
|
*/
|
||||||
|
public function getResultCacheDriver()
|
||||||
|
{
|
||||||
|
if ( ! isset($this->attributes[Doctrine::ATTR_CACHE])) {
|
||||||
|
throw new Doctrine_Exception('Result Cache driver not initialized.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->attributes[Doctrine::ATTR_CACHE];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* lastInsertId
|
* lastInsertId
|
||||||
*
|
*
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -34,7 +34,7 @@ class Doctrine_Query_From extends Doctrine_Query_Part
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* DQL FROM PARSER
|
* DQL FROM PARSER
|
||||||
* parses the from part of the query string
|
* parses the FROM part of the query string
|
||||||
*
|
*
|
||||||
* @param string $str
|
* @param string $str
|
||||||
* @return void
|
* @return void
|
||||||
@ -54,7 +54,6 @@ class Doctrine_Query_From extends Doctrine_Query_Part
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$last = '';
|
$last = '';
|
||||||
|
|
||||||
foreach ($parts as $k => $part) {
|
foreach ($parts as $k => $part) {
|
||||||
@ -64,7 +63,7 @@ class Doctrine_Query_From extends Doctrine_Query_Part
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$e = explode(' ', $part);
|
$e = explode(' ', $part);
|
||||||
|
|
||||||
if (end($e) == 'INNER' || end($e) == 'LEFT') {
|
if (end($e) == 'INNER' || end($e) == 'LEFT') {
|
||||||
$last = array_pop($e);
|
$last = array_pop($e);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
* $Id: Query.php 1296 2007-04-26 17:42:03Z zYne $
|
* $Id$
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
@ -27,8 +27,9 @@
|
|||||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||||
* @link www.phpdoctrine.com
|
* @link www.phpdoctrine.com
|
||||||
* @since 1.0
|
* @since 1.0
|
||||||
* @version $Revision: 1296 $
|
* @version $Revision$
|
||||||
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
|
||||||
*/
|
*/
|
||||||
class Doctrine_Query_Parser
|
class Doctrine_Query_Parser
|
||||||
{ }
|
{
|
||||||
|
|
||||||
|
}
|
@ -22,6 +22,12 @@ Doctrine::autoload('Doctrine_Query_Abstract');
|
|||||||
/**
|
/**
|
||||||
* Doctrine_RawSql
|
* Doctrine_RawSql
|
||||||
*
|
*
|
||||||
|
* Doctrine_RawSql is an implementation of Doctrine_Query_Abstract that skips the entire
|
||||||
|
* DQL parsing procedure. The "DQL" that is passed to a RawSql query object for execution
|
||||||
|
* is considered to be plain SQL and will be used "as is". The only query part that is special
|
||||||
|
* in a RawSql query is the SELECT part, which has a special syntax that provides Doctrine
|
||||||
|
* with the necessary information to properly hydrate the query results.
|
||||||
|
*
|
||||||
* @package Doctrine
|
* @package Doctrine
|
||||||
* @subpackage RawSql
|
* @subpackage RawSql
|
||||||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
||||||
@ -38,8 +44,20 @@ class Doctrine_RawSql extends Doctrine_Query_Abstract
|
|||||||
private $fields = array();
|
private $fields = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* parseQueryPart
|
* @deprecated
|
||||||
* parses given query part
|
*/
|
||||||
|
public function parseQueryPart($queryPartName, $queryPart, $append = false)
|
||||||
|
{
|
||||||
|
return $this->parseDqlQueryPart($queryPartName, $queryPart, $append);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* parseDqlQueryPart
|
||||||
|
* parses given DQL query part. Overrides Doctrine_Query_Abstract::parseDqlQueryPart().
|
||||||
|
* This implementation does no parsing at all, except of the SELECT portion of the query
|
||||||
|
* which is special in RawSql queries. The entire remaining parts are used "as is", so
|
||||||
|
* the user of the RawSql query is responsible for writing SQL that is portable between
|
||||||
|
* different DBMS.
|
||||||
*
|
*
|
||||||
* @param string $queryPartName the name of the query part
|
* @param string $queryPartName the name of the query part
|
||||||
* @param string $queryPart query part to be parsed
|
* @param string $queryPart query part to be parsed
|
||||||
@ -48,47 +66,60 @@ class Doctrine_RawSql extends Doctrine_Query_Abstract
|
|||||||
* the given query part stack with $queryPart
|
* the given query part stack with $queryPart
|
||||||
* @return Doctrine_Query this object
|
* @return Doctrine_Query this object
|
||||||
*/
|
*/
|
||||||
public function parseQueryPart($queryPartName, $queryPart, $append = false)
|
public function parseDqlQueryPart($queryPartName, $queryPart, $append = false)
|
||||||
{
|
{
|
||||||
if ($queryPartName == 'select') {
|
if ($queryPartName == 'select') {
|
||||||
$this->parseSelectFields($queryPart);
|
$this->_parseSelectFields($queryPart);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
if( ! isset($this->parts[$queryPartName])) {
|
if ( ! isset($this->parts[$queryPartName])) {
|
||||||
$this->parts[$queryPartName] = array();
|
$this->_sqlParts[$queryPartName] = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $append) {
|
if ( ! $append) {
|
||||||
$this->parts[$queryPartName] = array($queryPart);
|
$this->_sqlParts[$queryPartName] = array($queryPart);
|
||||||
}else {
|
} else {
|
||||||
$this->parts[$queryPartName][] = $queryPart;
|
$this->_sqlParts[$queryPartName][] = $queryPart;
|
||||||
}
|
}
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add select parts to fields
|
* Adds a DQL query part. Overrides Doctrine_Query_Abstract::_addDqlQueryPart().
|
||||||
|
* This implementation for RawSql parses the new parts right away, generating the SQL.
|
||||||
|
*/
|
||||||
|
protected function _addDqlQueryPart($queryPartName, $queryPart, $append = false)
|
||||||
|
{
|
||||||
|
return $this->parseQueryPart($queryPartName, $queryPart, $append);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add select parts to fields.
|
||||||
*
|
*
|
||||||
* @param $queryPart sting The name of the querypart
|
* @param $queryPart sting The name of the querypart
|
||||||
*/
|
*/
|
||||||
private function parseSelectFields($queryPart){
|
private function _parseSelectFields($queryPart){
|
||||||
preg_match_all('/{([^}{]*)}/U', $queryPart, $m);
|
preg_match_all('/{([^}{]*)}/U', $queryPart, $m);
|
||||||
$this->fields = $m[1];
|
$this->fields = $m[1];
|
||||||
$this->parts['select'] = array();
|
$this->_sqlParts['select'] = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* parseQuery
|
* parseDqlQuery
|
||||||
* parses an sql query and adds the parts to internal array
|
* parses an sql query and adds the parts to internal array.
|
||||||
|
* Overrides Doctrine_Query_Abstract::parseDqlQuery().
|
||||||
|
* This implementation simply tokenizes the provided query string and uses them
|
||||||
|
* as SQL parts right away.
|
||||||
*
|
*
|
||||||
* @param string $query query to be parsed
|
* @param string $query query to be parsed
|
||||||
* @return Doctrine_RawSql this object
|
* @return Doctrine_RawSql this object
|
||||||
*/
|
*/
|
||||||
public function parseQuery($query)
|
public function parseDqlQuery($query)
|
||||||
{
|
{
|
||||||
$this->parseSelectFields($query);
|
$this->_parseSelectFields($query);
|
||||||
$this->clear();
|
$this->clear();
|
||||||
|
|
||||||
$tokens = Doctrine_Tokenizer::sqlExplode($query,' ');
|
$tokens = $this->_tokenizer->sqlExplode($query, ' ');
|
||||||
|
|
||||||
$parts = array();
|
$parts = array();
|
||||||
foreach ($tokens as $key => $part) {
|
foreach ($tokens as $key => $part) {
|
||||||
@ -131,19 +162,19 @@ class Doctrine_RawSql extends Doctrine_Query_Abstract
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->parts = $parts;
|
$this->_sqlParts = $parts;
|
||||||
$this->parts['select'] = array();
|
$this->_sqlParts['select'] = array();
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getQuery
|
* getSqlQuery
|
||||||
* builds the sql query from the given query parts
|
* builds the sql query.
|
||||||
*
|
*
|
||||||
* @return string the built sql query
|
* @return string the built sql query
|
||||||
*/
|
*/
|
||||||
public function getQuery($params = array())
|
public function getSqlQuery($params = array())
|
||||||
{
|
{
|
||||||
$select = array();
|
$select = array();
|
||||||
|
|
||||||
@ -153,10 +184,10 @@ class Doctrine_RawSql extends Doctrine_Query_Abstract
|
|||||||
throw new Doctrine_RawSql_Exception('All selected fields in Sql query must be in format tableAlias.fieldName');
|
throw new Doctrine_RawSql_Exception('All selected fields in Sql query must be in format tableAlias.fieldName');
|
||||||
}
|
}
|
||||||
// try to auto-add component
|
// try to auto-add component
|
||||||
if ( ! $this->hasTableAlias($e[0])) {
|
if ( ! $this->hasSqlTableAlias($e[0])) {
|
||||||
try {
|
try {
|
||||||
$this->addComponent($e[0], ucwords($e[0]));
|
$this->addComponent($e[0], ucwords($e[0]));
|
||||||
} catch(Doctrine_Exception $exception) {
|
} catch (Doctrine_Exception $exception) {
|
||||||
throw new Doctrine_RawSql_Exception('The associated component for table alias ' . $e[0] . ' couldn\'t be found.');
|
throw new Doctrine_RawSql_Exception('The associated component for table alias ' . $e[0] . ' couldn\'t be found.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -164,7 +195,7 @@ class Doctrine_RawSql extends Doctrine_Query_Abstract
|
|||||||
$componentAlias = $this->getComponentAlias($e[0]);
|
$componentAlias = $this->getComponentAlias($e[0]);
|
||||||
|
|
||||||
if ($e[1] == '*') {
|
if ($e[1] == '*') {
|
||||||
foreach ($this->_aliasMap[$componentAlias]['table']->getColumnNames() as $name) {
|
foreach ($this->_queryComponents[$componentAlias]['table']->getColumnNames() as $name) {
|
||||||
$field = $e[0] . '.' . $name;
|
$field = $e[0] . '.' . $name;
|
||||||
|
|
||||||
$select[$componentAlias][$field] = $field . ' AS ' . $e[0] . '__' . $name;
|
$select[$componentAlias][$field] = $field . ' AS ' . $e[0] . '__' . $name;
|
||||||
@ -177,21 +208,21 @@ class Doctrine_RawSql extends Doctrine_Query_Abstract
|
|||||||
|
|
||||||
// force-add all primary key fields
|
// force-add all primary key fields
|
||||||
|
|
||||||
foreach ($this->getTableAliases() as $tableAlias => $componentAlias) {
|
foreach ($this->getTableAliasMap() as $tableAlias => $componentAlias) {
|
||||||
$map = $this->_aliasMap[$componentAlias];
|
$map = $this->_queryComponents[$componentAlias];
|
||||||
|
|
||||||
foreach ((array) $map['table']->getIdentifier() as $key) {
|
foreach ((array) $map['table']->getIdentifier() as $key) {
|
||||||
$field = $tableAlias . '.' . $key;
|
$field = $tableAlias . '.' . $key;
|
||||||
|
|
||||||
if ( ! isset($this->parts['select'][$field])) {
|
if ( ! isset($this->_sqlParts['select'][$field])) {
|
||||||
$select[$componentAlias][$field] = $field . ' AS ' . $tableAlias . '__' . $key;
|
$select[$componentAlias][$field] = $field . ' AS ' . $tableAlias . '__' . $key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// first add the fields of the root component
|
// first add the fields of the root component
|
||||||
reset($this->_aliasMap);
|
reset($this->_queryComponents);
|
||||||
$componentAlias = key($this->_aliasMap);
|
$componentAlias = key($this->_queryComponents);
|
||||||
|
|
||||||
$q = 'SELECT ' . implode(', ', $select[$componentAlias]);
|
$q = 'SELECT ' . implode(', ', $select[$componentAlias]);
|
||||||
unset($select[$componentAlias]);
|
unset($select[$componentAlias]);
|
||||||
@ -204,21 +235,21 @@ class Doctrine_RawSql extends Doctrine_Query_Abstract
|
|||||||
|
|
||||||
$string = $this->applyInheritance();
|
$string = $this->applyInheritance();
|
||||||
if ( ! empty($string)) {
|
if ( ! empty($string)) {
|
||||||
$this->parts['where'][] = $string;
|
$this->_sqlParts['where'][] = $string;
|
||||||
}
|
}
|
||||||
$copy = $this->parts;
|
$copy = $this->_sqlParts;
|
||||||
unset($copy['select']);
|
unset($copy['select']);
|
||||||
|
|
||||||
$q .= ( ! empty($this->parts['from']))? ' FROM ' . implode(' ', $this->parts['from']) : '';
|
$q .= ( ! empty($this->_sqlParts['from']))? ' FROM ' . implode(' ', $this->_sqlParts['from']) : '';
|
||||||
$q .= ( ! empty($this->parts['where']))? ' WHERE ' . implode(' AND ', $this->parts['where']) : '';
|
$q .= ( ! empty($this->_sqlParts['where']))? ' WHERE ' . implode(' AND ', $this->_sqlParts['where']) : '';
|
||||||
$q .= ( ! empty($this->parts['groupby']))? ' GROUP BY ' . implode(', ', $this->parts['groupby']) : '';
|
$q .= ( ! empty($this->_sqlParts['groupby']))? ' GROUP BY ' . implode(', ', $this->_sqlParts['groupby']) : '';
|
||||||
$q .= ( ! empty($this->parts['having']))? ' HAVING ' . implode(' AND ', $this->parts['having']) : '';
|
$q .= ( ! empty($this->_sqlParts['having']))? ' HAVING ' . implode(' AND ', $this->_sqlParts['having']) : '';
|
||||||
$q .= ( ! empty($this->parts['orderby']))? ' ORDER BY ' . implode(', ', $this->parts['orderby']) : '';
|
$q .= ( ! empty($this->_sqlParts['orderby']))? ' ORDER BY ' . implode(', ', $this->_sqlParts['orderby']) : '';
|
||||||
$q .= ( ! empty($this->parts['limit']))? ' LIMIT ' . implode(' ', $this->parts['limit']) : '';
|
$q .= ( ! empty($this->_sqlParts['limit']))? ' LIMIT ' . implode(' ', $this->_sqlParts['limit']) : '';
|
||||||
$q .= ( ! empty($this->parts['offset']))? ' OFFSET ' . implode(' ', $this->parts['offset']) : '';
|
$q .= ( ! empty($this->_sqlParts['offset']))? ' OFFSET ' . implode(' ', $this->_sqlParts['offset']) : '';
|
||||||
|
|
||||||
if ( ! empty($string)) {
|
if ( ! empty($string)) {
|
||||||
array_pop($this->parts['where']);
|
array_pop($this->_sqlParts['where']);
|
||||||
}
|
}
|
||||||
return $q;
|
return $q;
|
||||||
}
|
}
|
||||||
@ -255,8 +286,8 @@ class Doctrine_RawSql extends Doctrine_Query_Abstract
|
|||||||
|
|
||||||
$currPath = '';
|
$currPath = '';
|
||||||
|
|
||||||
if (isset($this->_aliasMap[$e[0]])) {
|
if (isset($this->_queryComponents[$e[0]])) {
|
||||||
$table = $this->_aliasMap[$e[0]]['table'];
|
$table = $this->_queryComponents[$e[0]]['table'];
|
||||||
|
|
||||||
$currPath = $parent = array_shift($e);
|
$currPath = $parent = array_shift($e);
|
||||||
}
|
}
|
||||||
@ -281,15 +312,15 @@ class Doctrine_RawSql extends Doctrine_Query_Abstract
|
|||||||
->getConnectionForComponent($component);
|
->getConnectionForComponent($component);
|
||||||
|
|
||||||
$table = $conn->getTable($component);
|
$table = $conn->getTable($component);
|
||||||
$this->_aliasMap[$componentAlias] = array('table' => $table);
|
$this->_queryComponents[$componentAlias] = array('table' => $table);
|
||||||
} else {
|
} else {
|
||||||
$relation = $table->getRelation($component);
|
$relation = $table->getRelation($component);
|
||||||
|
|
||||||
$this->_aliasMap[$componentAlias] = array('table' => $relation->getTable(),
|
$this->_queryComponents[$componentAlias] = array('table' => $relation->getTable(),
|
||||||
'parent' => $parent,
|
'parent' => $parent,
|
||||||
'relation' => $relation);
|
'relation' => $relation);
|
||||||
}
|
}
|
||||||
$this->addTableAlias($tableAlias, $componentAlias);
|
$this->addSqlTableAlias($tableAlias, $componentAlias);
|
||||||
|
|
||||||
$parent = $currPath;
|
$parent = $currPath;
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,9 @@ class Doctrine_Relation_Association extends Doctrine_Relation
|
|||||||
*/
|
*/
|
||||||
public function getRelationDql($count, $context = 'record')
|
public function getRelationDql($count, $context = 'record')
|
||||||
{
|
{
|
||||||
|
$table = $this->definition['refTable'];
|
||||||
$component = $this->definition['refTable']->getComponentName();
|
$component = $this->definition['refTable']->getComponentName();
|
||||||
|
|
||||||
switch ($context) {
|
switch ($context) {
|
||||||
case "record":
|
case "record":
|
||||||
$sub = substr(str_repeat("?, ", $count),0,-2);
|
$sub = substr(str_repeat("?, ", $count),0,-2);
|
||||||
@ -88,7 +90,7 @@ class Doctrine_Relation_Association extends Doctrine_Relation
|
|||||||
if (empty($id) || ! $this->definition['table']->getAttribute(Doctrine::ATTR_LOAD_REFERENCES)) {
|
if (empty($id) || ! $this->definition['table']->getAttribute(Doctrine::ATTR_LOAD_REFERENCES)) {
|
||||||
$coll = new Doctrine_Collection($this->getTable());
|
$coll = new Doctrine_Collection($this->getTable());
|
||||||
} else {
|
} else {
|
||||||
$coll = Doctrine_Query::create()->parseQuery($this->getRelationDql(1))->execute(array($id));
|
$coll = Doctrine_Query::create()->query($this->getRelationDql(1), array($id));
|
||||||
}
|
}
|
||||||
$coll->setReference($record, $this);
|
$coll->setReference($record, $this);
|
||||||
return $coll;
|
return $coll;
|
||||||
|
@ -109,7 +109,7 @@ class Doctrine_Tokenizer
|
|||||||
*
|
*
|
||||||
* parameters:
|
* parameters:
|
||||||
* $str = email LIKE 'John@example.com'
|
* $str = email LIKE 'John@example.com'
|
||||||
* $d = ' AND '
|
* $d = ' LIKE '
|
||||||
*
|
*
|
||||||
* would return an array:
|
* would return an array:
|
||||||
* array("email", "LIKE", "'John@example.com'")
|
* array("email", "LIKE", "'John@example.com'")
|
||||||
|
@ -47,16 +47,6 @@ class Doctrine_DataType_Enum_TestCase extends Doctrine_UnitTestCase
|
|||||||
$this->assertEqual($test->status, 'open');
|
$this->assertEqual($test->status, 'open');
|
||||||
$test->save();
|
$test->save();
|
||||||
|
|
||||||
try {
|
|
||||||
$query = new Doctrine_Query($this->connection);
|
|
||||||
$ret = $query->parseQuery('FROM EnumTest WHERE EnumTest.status = ?')
|
|
||||||
->execute(array('open'));
|
|
||||||
|
|
||||||
$this->assertEqual(count($ret), 1);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
$this->fail();
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$query = new Doctrine_Query($this->connection);
|
$query = new Doctrine_Query($this->connection);
|
||||||
$ret = $query->query("FROM EnumTest WHERE EnumTest.status = 'open'");
|
$ret = $query->query("FROM EnumTest WHERE EnumTest.status = 'open'");
|
||||||
|
@ -98,7 +98,7 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase
|
|||||||
$q = new Doctrine_Query();
|
$q = new Doctrine_Query();
|
||||||
$q->from('User u')->leftJoin('u.Phonenumber p');
|
$q->from('User u')->leftJoin('u.Phonenumber p');
|
||||||
$q->getQuery();
|
$q->getQuery();
|
||||||
|
//Doctrine::dump($q->getCachedForm(array('foo' => 'bar')));
|
||||||
$this->assertEqual($q->parseClause("CONCAT('u.name', u.name)"), "CONCAT('u.name', e.name)");
|
$this->assertEqual($q->parseClause("CONCAT('u.name', u.name)"), "CONCAT('u.name', e.name)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -106,8 +106,6 @@ class MyQuery extends Doctrine_Query
|
|||||||
{
|
{
|
||||||
public function preQuery()
|
public function preQuery()
|
||||||
{
|
{
|
||||||
if ($this->getRoot()->getComponentName() == 'User') {
|
$this->where('u.id = 4');
|
||||||
$this->where('u.id = 4');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,6 +125,7 @@ class Doctrine_RawSql_TestCase extends Doctrine_UnitTestCase
|
|||||||
$coll[5]->Phonenumber[0]->phonenumber;
|
$coll[5]->Phonenumber[0]->phonenumber;
|
||||||
$this->assertEqual($count, $this->conn->count());
|
$this->assertEqual($count, $this->conn->count());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAliasesAreSupportedInAddComponent()
|
public function testAliasesAreSupportedInAddComponent()
|
||||||
{
|
{
|
||||||
$query = new Doctrine_RawSql();
|
$query = new Doctrine_RawSql();
|
||||||
@ -161,8 +162,10 @@ class Doctrine_RawSql_TestCase extends Doctrine_UnitTestCase
|
|||||||
$this->assertTrue(is_numeric($coll[3]->id));
|
$this->assertTrue(is_numeric($coll[3]->id));
|
||||||
$this->assertTrue(is_numeric($coll[7]->id));
|
$this->assertTrue(is_numeric($coll[7]->id));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testConvenienceMethods()
|
public function testConvenienceMethods()
|
||||||
{
|
{
|
||||||
|
|
||||||
$query = new Doctrine_RawSql($this->connection);
|
$query = new Doctrine_RawSql($this->connection);
|
||||||
$query->select('{entity.name}')->from('entity');
|
$query->select('{entity.name}')->from('entity');
|
||||||
$query->addComponent('entity', 'User');
|
$query->addComponent('entity', 'User');
|
||||||
|
@ -145,7 +145,7 @@ $test->addTestCase($data_types);
|
|||||||
// Utility components
|
// Utility components
|
||||||
$plugins = new GroupTest('Plugin tests: View, Validator, Hook','plugins');
|
$plugins = new GroupTest('Plugin tests: View, Validator, Hook','plugins');
|
||||||
//$utility->addTestCase(new Doctrine_PessimisticLocking_TestCase());
|
//$utility->addTestCase(new Doctrine_PessimisticLocking_TestCase());
|
||||||
$plugins->addTestCase(new Doctrine_Plugin_TestCase());
|
//$plugins->addTestCase(new Doctrine_Plugin_TestCase());
|
||||||
$plugins->addTestCase(new Doctrine_View_TestCase());
|
$plugins->addTestCase(new Doctrine_View_TestCase());
|
||||||
$plugins->addTestCase(new Doctrine_AuditLog_TestCase());
|
$plugins->addTestCase(new Doctrine_AuditLog_TestCase());
|
||||||
$plugins->addTestCase(new Doctrine_Validator_TestCase());
|
$plugins->addTestCase(new Doctrine_Validator_TestCase());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user