Commit f26217c8 authored by zYne's avatar zYne

DQL core refactored

parent b50aceec
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
*/ */
Doctrine::autoload('Doctrine_Hydrate'); Doctrine::autoload('Doctrine_Hydrate');
/** /**
* Doctrine_Query2 * Doctrine_Query
* *
* @package Doctrine * @package Doctrine
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
...@@ -30,7 +30,7 @@ Doctrine::autoload('Doctrine_Hydrate'); ...@@ -30,7 +30,7 @@ Doctrine::autoload('Doctrine_Hydrate');
* @version $Revision: 1296 $ * @version $Revision: 1296 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi> * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/ */
class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable class Doctrine_Query extends Doctrine_Hydrate2 implements Countable
{ {
/** /**
* @param array $subqueryAliases the table aliases needed in some LIMIT subqueries * @param array $subqueryAliases the table aliases needed in some LIMIT subqueries
...@@ -88,7 +88,7 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable ...@@ -88,7 +88,7 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable
*/ */
public static function create() public static function create()
{ {
return new Doctrine_Query2(); return new Doctrine_Query();
} }
/** /**
* isSubquery * isSubquery
...@@ -205,7 +205,7 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable ...@@ -205,7 +205,7 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable
*/ */
public function parseSelect($dql) public function parseSelect($dql)
{ {
$refs = Doctrine_Query::bracketExplode($dql, ','); $refs = Doctrine_Tokenizer::bracketExplode($dql, ',');
foreach ($refs as $reference) { foreach ($refs as $reference) {
if (strpos($reference, '(') !== false) { if (strpos($reference, '(') !== false) {
...@@ -237,7 +237,7 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable ...@@ -237,7 +237,7 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable
*/ */
public function parseSubselect($reference) public function parseSubselect($reference)
{ {
$e = Doctrine_Query::bracketExplode($reference, ' '); $e = Doctrine_Tokenizer::bracketExplode($reference, ' ');
$alias = $e[1]; $alias = $e[1];
if (count($e) > 2) { if (count($e) > 2) {
...@@ -253,7 +253,7 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable ...@@ -253,7 +253,7 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable
} }
public function parseAggregateFunction2($func) public function parseAggregateFunction2($func)
{ {
$e = Doctrine_Query::bracketExplode($func, ' '); $e = Doctrine_Tokenizer::bracketExplode($func, ' ');
$func = $e[0]; $func = $e[0];
$pos = strpos($func, '('); $pos = strpos($func, '(');
...@@ -1132,7 +1132,7 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable ...@@ -1132,7 +1132,7 @@ class Doctrine_Query2 extends Doctrine_Hydrate2 implements Countable
public function distinct($flag = true) public function distinct($flag = true)
{ {
$this->_parts['distinct'] = (bool) $flag; $this->_parts['distinct'] = (bool) $flag;
return $this; return $this;
} }
......
...@@ -87,30 +87,30 @@ class Doctrine_RawSql extends Doctrine_Hydrate ...@@ -87,30 +87,30 @@ class Doctrine_RawSql extends Doctrine_Hydrate
foreach ($e as $k => $part) { foreach ($e as $k => $part) {
$low = strtolower($part); $low = strtolower($part);
switch (strtolower($part)) { switch (strtolower($part)) {
case "select": case 'select':
case "from": case 'from':
case "where": case 'where':
case "limit": case 'limit':
case "offset": case 'offset':
case "having": case 'having':
$p = $low; $p = $low;
if ( ! isset($parts[$low])) { if ( ! isset($parts[$low])) {
$parts[$low] = array(); $parts[$low] = array();
} }
break; break;
case "order": case 'order':
case "group": case 'group':
$i = ($k + 1); $i = ($k + 1);
if (isset($e[$i]) && strtolower($e[$i]) === "by") { if (isset($e[$i]) && strtolower($e[$i]) === 'by') {
$p = $low; $p = $low;
$p .= "by"; $p .= 'by';
$parts[$low."by"] = array(); $parts[$low.'by'] = array();
} else { } else {
$parts[$p][] = $part; $parts[$p][] = $part;
} }
break; break;
case "by": case 'by':
continue; continue;
default: default:
if ( ! isset($parts[$p][0])) { if ( ! isset($parts[$p][0])) {
...@@ -118,11 +118,11 @@ class Doctrine_RawSql extends Doctrine_Hydrate ...@@ -118,11 +118,11 @@ class Doctrine_RawSql extends Doctrine_Hydrate
} else { } else {
$parts[$p][0] .= ' '.$part; $parts[$p][0] .= ' '.$part;
} }
}; }
}; }
$this->parts = $parts; $this->parts = $parts;
$this->parts["select"] = array(); $this->parts['select'] = array();
return $this; return $this;
} }
...@@ -149,12 +149,12 @@ class Doctrine_RawSql extends Doctrine_Hydrate ...@@ -149,12 +149,12 @@ class Doctrine_RawSql extends Doctrine_Hydrate
if ($e[1] == '*') { if ($e[1] == '*') {
foreach ($this->tables[$e[0]]->getColumnNames() as $name) { foreach ($this->tables[$e[0]]->getColumnNames() as $name) {
$field = $e[0].".".$name; $field = $e[0] . '.' . $name;
$this->parts["select"][$field] = $field." AS ".$e[0]."__".$name; $this->parts['select'][$field] = $field . ' AS ' . $e[0] . '__' . $name;
} }
} else { } else {
$field = $e[0].".".$e[1]; $field = $e[0] . '.' . $e[1];
$this->parts["select"][$field] = $field." AS ".$e[0]."__".$e[1]; $this->parts['select'][$field] = $field . ' AS ' . $e[0] . '__' . $e[1];
} }
} }
...@@ -163,13 +163,13 @@ class Doctrine_RawSql extends Doctrine_Hydrate ...@@ -163,13 +163,13 @@ class Doctrine_RawSql extends Doctrine_Hydrate
foreach ($this->tableAliases as $alias) { foreach ($this->tableAliases as $alias) {
foreach ($this->tables[$alias]->getPrimaryKeys() as $key) { foreach ($this->tables[$alias]->getPrimaryKeys() as $key) {
$field = $alias . '.' . $key; $field = $alias . '.' . $key;
if ( ! isset($this->parts["select"][$field])) { if ( ! isset($this->parts['select'][$field])) {
$this->parts["select"][$field] = $field." AS ".$alias."__".$key; $this->parts['select'][$field] = $field . ' AS ' . $alias . '__' . $key;
} }
} }
} }
$q = 'SELECT '.implode(', ', $this->parts['select']); $q = 'SELECT ' . implode(', ', $this->parts['select']);
$string = $this->applyInheritance(); $string = $this->applyInheritance();
if ( ! empty($string)) { if ( ! empty($string)) {
...@@ -183,8 +183,8 @@ class Doctrine_RawSql extends Doctrine_Hydrate ...@@ -183,8 +183,8 @@ class Doctrine_RawSql extends Doctrine_Hydrate
$q .= ( ! empty($this->parts['groupby']))? ' GROUP BY ' . implode(', ', $this->parts['groupby']) : ''; $q .= ( ! empty($this->parts['groupby']))? ' GROUP BY ' . implode(', ', $this->parts['groupby']) : '';
$q .= ( ! empty($this->parts['having']))? ' HAVING ' . implode(' ', $this->parts['having']) : ''; $q .= ( ! empty($this->parts['having']))? ' HAVING ' . implode(' ', $this->parts['having']) : '';
$q .= ( ! empty($this->parts['orderby']))? ' ORDER BY ' . implode(' ', $this->parts['orderby']) : ''; $q .= ( ! empty($this->parts['orderby']))? ' ORDER BY ' . implode(' ', $this->parts['orderby']) : '';
$q .= ( ! empty($this->parts['limit']))? ' LIMIT ' . implode(' ', $this->parts['limit']) : ''; $q .= ( ! empty($this->parts['limit']))? ' LIMIT ' . implode(' ', $this->parts['limit']) : '';
$q .= ( ! empty($this->parts['offset']))? ' OFFSET ' . implode(' ', $this->parts['offset']) : ''; $q .= ( ! empty($this->parts['offset']))? ' OFFSET ' . implode(' ', $this->parts['offset']) : '';
if ( ! empty($string)) { if ( ! empty($string)) {
array_pop($this->parts['where']); array_pop($this->parts['where']);
...@@ -216,8 +216,10 @@ class Doctrine_RawSql extends Doctrine_Hydrate ...@@ -216,8 +216,10 @@ class Doctrine_RawSql extends Doctrine_Hydrate
foreach ($e as $k => $component) { foreach ($e as $k => $component) {
$currPath .= '.' . $component; $currPath .= '.' . $component;
if ($k == 0)
if ($k == 0) {
$currPath = substr($currPath,1); $currPath = substr($currPath,1);
}
if (isset($this->tableAliases[$currPath])) { if (isset($this->tableAliases[$currPath])) {
$alias = $this->tableAliases[$currPath]; $alias = $this->tableAliases[$currPath];
...@@ -230,12 +232,12 @@ class Doctrine_RawSql extends Doctrine_Hydrate ...@@ -230,12 +232,12 @@ class Doctrine_RawSql extends Doctrine_Hydrate
} }
$table = $this->conn->getTable($component); $table = $this->conn->getTable($component);
$this->tables[$alias] = $table; $this->tables[$alias] = $table;
$this->fetchModes[$alias] = Doctrine::FETCH_IMMEDIATE;
$this->tableAliases[$currPath] = $alias; $this->tableAliases[$currPath] = $alias;
if ($k !== 0) { if ($k !== 0) {
$this->joins[$alias] = $prevAlias; $this->joins[$alias] = $prevAlias;
} }
$prevAlias = $alias; $prevAlias = $alias;
$prevPath = $currPath; $prevPath = $currPath;
} }
......
...@@ -19,9 +19,11 @@ ...@@ -19,9 +19,11 @@
* <http://www.phpdoctrine.com>. * <http://www.phpdoctrine.com>.
*/ */
/** /**
* Doctrine_Table represents a database table * Doctrine_Table
* each Doctrine_Table holds the information of foreignKeys and associations *
* * This class represents a database table.
* Each Doctrine_Table holds the information of foreignKeys and associations
* to other tables.
* *
* @author Konsta Vesterinen <kvesteri@cc.hut.fi> * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @package Doctrine * @package Doctrine
...@@ -54,10 +56,6 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable ...@@ -54,10 +56,6 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
* @var integer $identifierType the type of identifier this table uses * @var integer $identifierType the type of identifier this table uses
*/ */
private $identifierType; private $identifierType;
/**
* @var string $query cached simple query
*/
private $query;
/** /**
* @var Doctrine_Connection $conn Doctrine_Connection object that created this table * @var Doctrine_Connection $conn Doctrine_Connection object that created this table
*/ */
...@@ -150,18 +148,18 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable ...@@ -150,18 +148,18 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
* *
* -- treeOptions the tree options * -- treeOptions the tree options
*/ */
protected $options = array('name' => null, protected $options = array('name' => null,
'tableName' => null, 'tableName' => null,
'sequenceName' => null, 'sequenceName' => null,
'inheritanceMap' => array(), 'inheritanceMap' => array(),
'enumMap' => array(), 'enumMap' => array(),
'engine' => null, 'engine' => null,
'charset' => null, 'charset' => null,
'collation' => null, 'collation' => null,
'treeImpl' => null, 'treeImpl' => null,
'treeOptions' => null, 'treeOptions' => null,
'indexes' => array(), 'indexes' => array(),
); );
/** /**
* @var Doctrine_Tree $tree tree object associated with this table * @var Doctrine_Tree $tree tree object associated with this table
*/ */
...@@ -284,19 +282,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable ...@@ -284,19 +282,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
$this->identifier = $pk; $this->identifier = $pk;
} }
} }
}; }
/**
if ( ! isset($definition['values'])) {
throw new Doctrine_Table_Exception('No values set for enum column ' . $name);
}
if ( ! is_array($definition['values'])) {
throw new Doctrine_Table_Exception('Enum column values should be specified as an array.');
}
*/
} }
} else { } else {
throw new Doctrine_Table_Exception("Class '$name' has no table definition."); throw new Doctrine_Table_Exception("Class '$name' has no table definition.");
...@@ -313,9 +299,6 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable ...@@ -313,9 +299,6 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
array_pop($names); array_pop($names);
$this->options['parents'] = $names; $this->options['parents'] = $names;
$this->query = 'SELECT ' . implode(', ', array_keys($this->columns)) . ' FROM ' . $this->getTableName();
$this->repository = new Doctrine_Table_Repository($this); $this->repository = new Doctrine_Table_Repository($this);
} }
/** /**
...@@ -1043,7 +1026,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable ...@@ -1043,7 +1026,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
$id = array_values($id); $id = array_values($id);
} }
$query = $this->query . ' WHERE ' . implode(' = ? AND ', $this->primaryKeys) . ' = ?'; $query = 'SELECT ' . implode(', ', array_keys($this->columns)) . ' FROM ' . $this->getTableName() . ' WHERE ' . implode(' = ? AND ', $this->primaryKeys) . ' = ?';
$query = $this->applyInheritance($query); $query = $this->applyInheritance($query);
$params = array_merge($id, array_values($this->options['inheritanceMap'])); $params = array_merge($id, array_values($this->options['inheritanceMap']));
...@@ -1430,15 +1413,6 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable ...@@ -1430,15 +1413,6 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
$data = $stmt->fetch(PDO::FETCH_NUM); $data = $stmt->fetch(PDO::FETCH_NUM);
return isset($data[0])?$data[0]:1; return isset($data[0])?$data[0]:1;
} }
/**
* returns simple cached query
*
* @return string
*/
final public function getQuery()
{
return $this->query;
}
/** /**
* returns internal data, used by Doctrine_Record instances * returns internal data, used by Doctrine_Record instances
* when retrieving data from database * when retrieving data from database
......
This diff is collapsed.
...@@ -999,7 +999,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun ...@@ -999,7 +999,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
case Doctrine_Record::STATE_TCLEAN: case Doctrine_Record::STATE_TCLEAN:
// do nothing // do nothing
break; break;
}; }
$record->getTable()->getAttribute(Doctrine::ATTR_LISTENER)->onSave($record); $record->getTable()->getAttribute(Doctrine::ATTR_LISTENER)->onSave($record);
} }
......
This diff is collapsed.
...@@ -50,8 +50,9 @@ class Doctrine_Hydrate_Alias ...@@ -50,8 +50,9 @@ class Doctrine_Hydrate_Alias
$name = substr($alias, 0, 1); $name = substr($alias, 0, 1);
$i = ((int) substr($alias, 1)); $i = ((int) substr($alias, 1));
if ($i == 0) if ($i == 0) {
$i = 1; $i = 1;
}
$newIndex = ($this->shortAliasIndexes[$name] + $i); $newIndex = ($this->shortAliasIndexes[$name] + $i);
...@@ -65,6 +66,15 @@ class Doctrine_Hydrate_Alias ...@@ -65,6 +66,15 @@ class Doctrine_Hydrate_Alias
{ {
return (isset($this->shortAliases[$tableName])); return (isset($this->shortAliases[$tableName]));
} }
public function getComponentAlias($tableAlias)
{
if ( ! isset($this->shortAliases[$tableAlias])) {
throw new Doctrine_Hydrate_Exception('Unknown table alias ' . $tableAlias);
}
return $this->shortAliases[$tableAlias];
}
public function getShortAliasIndex($alias) public function getShortAliasIndex($alias)
{ {
if ( ! isset($this->shortAliasIndexes[$alias])) { if ( ! isset($this->shortAliasIndexes[$alias])) {
...@@ -72,7 +82,7 @@ class Doctrine_Hydrate_Alias ...@@ -72,7 +82,7 @@ class Doctrine_Hydrate_Alias
} }
return $this->shortAliasIndexes[$alias]; return $this->shortAliasIndexes[$alias];
} }
public function generateShortAlias($tableName) public function generateShortAlias($componentAlias, $tableName)
{ {
$char = strtolower(substr($tableName, 0, 1)); $char = strtolower(substr($tableName, 0, 1));
...@@ -84,18 +94,35 @@ class Doctrine_Hydrate_Alias ...@@ -84,18 +94,35 @@ class Doctrine_Hydrate_Alias
while (isset($this->shortAliases[$alias])) { while (isset($this->shortAliases[$alias])) {
$alias = $char . ++$this->shortAliasIndexes[$alias]; $alias = $char . ++$this->shortAliasIndexes[$alias];
} }
$this->shortAliases[$alias] = $tableName;
$this->shortAliases[$alias] = $componentAlias;
return $alias; return $alias;
} }
/**
public function getShortAlias($tableName) * getShortAlias
* 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 getShortAlias($componentAlias, $tableName = null)
{ {
$alias = array_search($tableName, $this->shortAliases); $alias = array_search($componentAlias, $this->shortAliases);
if ($alias !== false) { if ($alias !== false) {
return $alias; return $alias;
} }
return $this->generateShortAlias($tableName);
if ($tableName === null) {
throw new Doctrine_Hydrate_Exception("Couldn't get short alias for " . $componentAlias);
}
return $this->generateShortAlias($componentAlias, $tableName);
} }
} }
...@@ -63,13 +63,14 @@ class Doctrine_Lib ...@@ -63,13 +63,14 @@ class Doctrine_Lib
*/ */
public static function getRecordAsString(Doctrine_Record $record) public static function getRecordAsString(Doctrine_Record $record)
{ {
$r[] = "<pre>"; $r[] = '<pre>';
$r[] = "Component : ".$record->getTable()->getComponentName(); $r[] = 'Component : ' . $record->getTable()->getComponentName();
$r[] = "ID : ".$record->obtainIdentifier(); $r[] = 'ID : ' . $record->obtainIdentifier();
$r[] = "References : ".count($record->getReferences()); $r[] = 'References : ' . count($record->getReferences());
$r[] = "State : ".Doctrine_Lib::getRecordStateAsString($record->getState()); $r[] = 'State : ' . Doctrine_Lib::getRecordStateAsString($record->getState());
$r[] = "OID : ".$record->getOID(); $r[] = 'OID : ' . $record->getOID();
$r[] = "</pre>"; $r[] = 'data : ' . Doctrine::dump($record->getData(), false);
$r[] = '</pre>';
return implode("\n",$r)."<br />"; return implode("\n",$r)."<br />";
} }
/** /**
...@@ -84,12 +85,12 @@ class Doctrine_Lib ...@@ -84,12 +85,12 @@ class Doctrine_Lib
public static function getCollectionAsXml(Doctrine_Collection $collection, SimpleXMLElement $incomming_xml = null){ public static function getCollectionAsXml(Doctrine_Collection $collection, SimpleXMLElement $incomming_xml = null){
$collection_name = Doctrine_Lib::plurelize($collection->getTable()->name); $collectionName = Doctrine_Lib::plurelize($collection->getTable()->name);
if (!isset($incomming_xml)) { if ( ! isset($incomming_xml)) {
$xml = new SimpleXMLElement("<" . $collection_name . "></" . $collection_name . ">"); $xml = new SimpleXMLElement("<" . $collectionName . "></" . $collectionName . ">");
} else { } else {
$xml = $incomming_xml->addChild($collection_name); $xml = $incomming_xml->addChild($collectionName);
} }
foreach ($collection as $key => $record) { foreach ($collection as $key => $record) {
Doctrine_Lib::getRecordAsXml($record, $xml); Doctrine_Lib::getRecordAsXml($record, $xml);
......
This diff is collapsed.
...@@ -39,32 +39,32 @@ abstract class Doctrine_Query_Condition extends Doctrine_Query_Part ...@@ -39,32 +39,32 @@ abstract class Doctrine_Query_Condition extends Doctrine_Query_Part
* @param string $str * @param string $str
* @return string * @return string
*/ */
final public function parse($str) public function _parse($str)
{ {
$tmp = trim($str); $tmp = trim($str);
$parts = Doctrine_Query::bracketExplode($str, array(' \&\& ', ' AND '), '(', ')'); $parts = Doctrine_Tokenizer::bracketExplode($str, array(' \&\& ', ' AND '), '(', ')');
if (count($parts) > 1) { if (count($parts) > 1) {
$ret = array(); $ret = array();
foreach ($parts as $part) { foreach ($parts as $part) {
$part = Doctrine_Query::bracketTrim($part, '(', ')'); $part = Doctrine_Tokenizer::bracketTrim($part, '(', ')');
$ret[] = $this->parse($part); $ret[] = $this->_parse($part);
} }
$r = implode(' AND ',$ret); $r = implode(' AND ', $ret);
} else { } else {
$parts = Doctrine_Query::bracketExplode($str, array(' \|\| ', ' OR '), '(', ')'); $parts = Doctrine_Tokenizer::bracketExplode($str, array(' \|\| ', ' OR '), '(', ')');
if (count($parts) > 1) { if (count($parts) > 1) {
$ret = array(); $ret = array();
foreach ($parts as $part) { foreach ($parts as $part) {
$part = Doctrine_Query::bracketTrim($part, '(', ')'); $part = Doctrine_Tokenizer::bracketTrim($part, '(', ')');
$ret[] = $this->parse($part); $ret[] = $this->_parse($part);
} }
$r = implode(' OR ', $ret); $r = implode(' OR ', $ret);
} else { } else {
if (substr($parts[0],0,1) == '(' && substr($parts[0],-1) == ')') { if (substr($parts[0],0,1) == '(' && substr($parts[0], -1) == ')') {
return $this->parse(substr($parts[0],1,-1)); return $this->_parse(substr($parts[0], 1, -1));
} else { } else {
return $this->load($parts[0]); return $this->load($parts[0]);
} }
...@@ -73,6 +73,9 @@ abstract class Doctrine_Query_Condition extends Doctrine_Query_Part ...@@ -73,6 +73,9 @@ abstract class Doctrine_Query_Condition extends Doctrine_Query_Part
return '(' . $r . ')'; return '(' . $r . ')';
} }
/** /**
* parses a literal value and returns the parsed value * parses a literal value and returns the parsed value
* *
...@@ -88,7 +91,7 @@ abstract class Doctrine_Query_Condition extends Doctrine_Query_Part ...@@ -88,7 +91,7 @@ abstract class Doctrine_Query_Condition extends Doctrine_Query_Part
if (strpos($value, '\'') === false) { if (strpos($value, '\'') === false) {
// parse booleans // parse booleans
$value = $this->query->getConnection() $value = $this->query->getConnection()
->dataDict->parseBoolean($value); ->dataDict->parseBoolean($value);
$a = explode('.', $value); $a = explode('.', $value);
......
...@@ -31,7 +31,7 @@ Doctrine::autoload("Doctrine_Query_Part"); ...@@ -31,7 +31,7 @@ Doctrine::autoload("Doctrine_Query_Part");
* @author Konsta Vesterinen <kvesteri@cc.hut.fi> * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/ */
class Doctrine_Query_From extends Doctrine_Query_Part 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
...@@ -39,11 +39,10 @@ class Doctrine_Query_From extends Doctrine_Query_Part ...@@ -39,11 +39,10 @@ class Doctrine_Query_From extends Doctrine_Query_Part
* @param string $str * @param string $str
* @return void * @return void
*/ */
final public function parse($str) public function parse($str)
{ {
$str = trim($str); $str = trim($str);
$parts = Doctrine_Query::bracketExplode($str, 'JOIN'); $parts = Doctrine_Tokenizer::bracketExplode($str, 'JOIN');
$operator = false; $operator = false;
...@@ -52,8 +51,10 @@ class Doctrine_Query_From extends Doctrine_Query_Part ...@@ -52,8 +51,10 @@ class Doctrine_Query_From extends Doctrine_Query_Part
$operator = ':'; $operator = ':';
case 'LEFT': case 'LEFT':
array_shift($parts); array_shift($parts);
break;
} }
$last = ''; $last = '';
foreach ($parts as $k => $part) { foreach ($parts as $k => $part) {
...@@ -70,7 +71,7 @@ class Doctrine_Query_From extends Doctrine_Query_Part ...@@ -70,7 +71,7 @@ class Doctrine_Query_From extends Doctrine_Query_Part
} }
$part = implode(' ', $e); $part = implode(' ', $e);
foreach (Doctrine_Query::bracketExplode($part, ',') as $reference) { foreach (Doctrine_Tokenizer::bracketExplode($part, ',') as $reference) {
$reference = trim($reference); $reference = trim($reference);
$e = explode('.', $reference); $e = explode('.', $reference);
...@@ -83,6 +84,7 @@ class Doctrine_Query_From extends Doctrine_Query_Part ...@@ -83,6 +84,7 @@ class Doctrine_Query_From extends Doctrine_Query_Part
$operator = ($last == 'INNER') ? ':' : '.'; $operator = ($last == 'INNER') ? ':' : '.';
} }
return $this->query;
} }
} }
...@@ -39,7 +39,7 @@ class Doctrine_Query_Groupby extends Doctrine_Query_Part ...@@ -39,7 +39,7 @@ class Doctrine_Query_Groupby extends Doctrine_Query_Part
* @param string $str * @param string $str
* @return void * @return void
*/ */
final public function parse($str) public function parse($str, $append = false)
{ {
$r = array(); $r = array();
foreach (explode(',', $str) as $reference) { foreach (explode(',', $str) as $reference) {
...@@ -47,10 +47,15 @@ class Doctrine_Query_Groupby extends Doctrine_Query_Part ...@@ -47,10 +47,15 @@ class Doctrine_Query_Groupby extends Doctrine_Query_Part
$e = explode('.', $reference); $e = explode('.', $reference);
$field = array_pop($e); $field = array_pop($e);
$ref = implode('.', $e); $ref = implode('.', $e);
$table = $this->query->load($ref); $this->query->load($ref);
$component = $table->getComponentName();
$r[] = $this->query->getTableAlias($ref).".".$field; $r[] = $this->query->getTableAlias($ref) . '.' . $field;
}
if ($append) {
$this->query->addQueryPart('groupby', implode(', ', $r));
} else {
$this->query->setQueryPart('groupby', implode(', ', $r));
} }
return implode(', ', $r); return $this->query;
} }
} }
...@@ -32,6 +32,15 @@ Doctrine::autoload('Doctrine_Query_Condition'); ...@@ -32,6 +32,15 @@ Doctrine::autoload('Doctrine_Query_Condition');
*/ */
class Doctrine_Query_Having extends Doctrine_Query_Condition class Doctrine_Query_Having extends Doctrine_Query_Condition
{ {
public function parse($str, $append = false)
{
if ($append) {
$this->query->addQueryPart('having', $this->_parse($str));
} else {
$this->query->setQueryPart('having', $this->_parse($str));
}
return $this->query;
}
/** /**
* DQL Aggregate Function parser * DQL Aggregate Function parser
* *
...@@ -47,7 +56,7 @@ class Doctrine_Query_Having extends Doctrine_Query_Condition ...@@ -47,7 +56,7 @@ class Doctrine_Query_Having extends Doctrine_Query_Condition
$name = substr($func, 0, $pos); $name = substr($func, 0, $pos);
$func = substr($func, ($pos + 1), -1); $func = substr($func, ($pos + 1), -1);
$params = Doctrine_Query::bracketExplode($func, ',', '(', ')'); $params = Doctrine_Tokenizer::bracketExplode($func, ',', '(', ')');
foreach ($params as $k => $param) { foreach ($params as $k => $param) {
$params[$k] = $this->parseAggregateFunction($param); $params[$k] = $this->parseAggregateFunction($param);
...@@ -64,8 +73,8 @@ class Doctrine_Query_Having extends Doctrine_Query_Condition ...@@ -64,8 +73,8 @@ class Doctrine_Query_Having extends Doctrine_Query_Condition
if (count($a) > 1) { if (count($a) > 1) {
$field = array_pop($a); $field = array_pop($a);
$reference = implode('.', $a); $reference = implode('.', $a);
$table = $this->query->load($reference, false); $map = $this->query->load($reference, false);
$field = $table->getColumnName($field); $field = $map['table']->getColumnName($field);
$func = $this->query->getTableAlias($reference) . '.' . $field; $func = $this->query->getTableAlias($reference) . '.' . $field;
} else { } else {
$field = end($a); $field = end($a);
...@@ -86,7 +95,7 @@ class Doctrine_Query_Having extends Doctrine_Query_Condition ...@@ -86,7 +95,7 @@ class Doctrine_Query_Having extends Doctrine_Query_Condition
*/ */
final public function load($having) final public function load($having)
{ {
$e = Doctrine_Query::bracketExplode($having, ' ', '(', ')'); $e = Doctrine_Tokenizer::bracketExplode($having, ' ', '(', ')');
$r = array_shift($e); $r = array_shift($e);
$t = explode('(', $r); $t = explode('(', $r);
......
...@@ -36,7 +36,7 @@ class Doctrine_Query_JoinCondition extends Doctrine_Query_Condition ...@@ -36,7 +36,7 @@ class Doctrine_Query_JoinCondition extends Doctrine_Query_Condition
{ {
$condition = trim($condition); $condition = trim($condition);
$e = Doctrine_Query::sqlExplode($condition); $e = Doctrine_Tokenizer::sqlExplode($condition);
if(count($e) > 2) { if(count($e) > 2) {
$a = explode('.', $e[0]); $a = explode('.', $e[0]);
...@@ -46,15 +46,15 @@ class Doctrine_Query_JoinCondition extends Doctrine_Query_Condition ...@@ -46,15 +46,15 @@ class Doctrine_Query_JoinCondition extends Doctrine_Query_Condition
$value = $e[2]; $value = $e[2];
$alias = $this->query->getTableAlias($reference); $alias = $this->query->getTableAlias($reference);
$map = $this->query->getDeclaration($reference);
$table = $this->query->getTable($alias); $table = $map['table'];
// check if value is enumerated value // check if value is enumerated value
$enumIndex = $table->enumIndex($field, trim($value, "'")); $enumIndex = $table->enumIndex($field, trim($value, "'"));
if (substr($value, 0, 1) == '(') { if (substr($value, 0, 1) == '(') {
// trim brackets // trim brackets
$trimmed = Doctrine_Query::bracketTrim($value); $trimmed = Doctrine_Tokenizer::bracketTrim($value);
if (substr($trimmed, 0, 4) == 'FROM' || substr($trimmed, 0, 6) == 'SELECT') { if (substr($trimmed, 0, 4) == 'FROM' || substr($trimmed, 0, 6) == 'SELECT') {
// subquery found // subquery found
...@@ -64,7 +64,7 @@ class Doctrine_Query_JoinCondition extends Doctrine_Query_Condition ...@@ -64,7 +64,7 @@ class Doctrine_Query_JoinCondition extends Doctrine_Query_Condition
$value = '(' . substr($trimmed, 4) . ')'; $value = '(' . substr($trimmed, 4) . ')';
} else { } else {
// simple in expression found // simple in expression found
$e = Doctrine_Query::sqlExplode($trimmed, ','); $e = Doctrine_Tokenizer::sqlExplode($trimmed, ',');
$value = array(); $value = array();
foreach ($e as $part) { foreach ($e as $part) {
......
<?php
/*
* $Id: Where.php 1352 2007-05-15 10:07:05Z 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
* <http://www.phpdoctrine.com>.
*/
/**
* Doctrine_Query_Limit
*
* @package Doctrine
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision: 1352 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Query_Limit extends Doctrine_Query_Part
{
public function parse($limit)
{
$this->query->setQueryPart('limit', (int) $limit);
return $this->query;
}
}
<?php
/*
* $Id: Where.php 1352 2007-05-15 10:07:05Z 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
* <http://www.phpdoctrine.com>.
*/
/**
* Doctrine_Query_Offset
*
* @package Doctrine
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision: 1352 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
class Doctrine_Query_Offset extends Doctrine_Query_Part
{
public function parse($offset)
{
$this->query->setQueryPart('offset', (int) $offset);
return $this->query;
}
}
...@@ -39,7 +39,7 @@ class Doctrine_Query_Orderby extends Doctrine_Query_Part ...@@ -39,7 +39,7 @@ class Doctrine_Query_Orderby extends Doctrine_Query_Part
* @param string $str * @param string $str
* @return void * @return void
*/ */
public function parse($str) public function parse($str, $append = false)
{ {
$ret = array(); $ret = array();
...@@ -53,12 +53,10 @@ class Doctrine_Query_Orderby extends Doctrine_Query_Part ...@@ -53,12 +53,10 @@ class Doctrine_Query_Orderby extends Doctrine_Query_Part
$reference = implode('.', $a); $reference = implode('.', $a);
$name = end($a); $name = end($a);
$this->query->load($reference, false); $map = $this->query->load($reference, false);
$alias = $this->query->getTableAlias($reference); $tableAlias = $this->query->getTableAlias($reference);
$tname = $this->query->getTable($alias)->getTableName(); $r = $tableAlias . '.' . $field;
$r = $alias . '.' . $field;
} else { } else {
...@@ -72,6 +70,11 @@ class Doctrine_Query_Orderby extends Doctrine_Query_Part ...@@ -72,6 +70,11 @@ class Doctrine_Query_Orderby extends Doctrine_Query_Part
$ret[] = $r; $ret[] = $r;
} }
return implode(', ', $ret); if ($append) {
$this->query->addQueryPart('orderby', implode(', ', $ret));
} else {
$this->query->setQueryPart('orderby', implode(', ', $ret));
}
return $this->query;
} }
} }
...@@ -34,11 +34,11 @@ class Doctrine_Query_Set extends Doctrine_Query_Part ...@@ -34,11 +34,11 @@ class Doctrine_Query_Set extends Doctrine_Query_Part
{ {
public function parse($dql) public function parse($dql)
{ {
$parts = Doctrine_Query::sqlExplode($dql, ','); $parts = Doctrine_Tokenizer::sqlExplode($dql, ',');
$result = array(); $result = array();
foreach ($parts as $part) { foreach ($parts as $part) {
$set = Doctrine_Query::sqlExplode($part, '='); $set = Doctrine_Tokenizer::sqlExplode($part, '=');
$e = explode('.', trim($set[0])); $e = explode('.', trim($set[0]));
$field = array_pop($e); $field = array_pop($e);
...@@ -46,12 +46,15 @@ class Doctrine_Query_Set extends Doctrine_Query_Part ...@@ -46,12 +46,15 @@ class Doctrine_Query_Set extends Doctrine_Query_Part
$reference = implode('.', $e); $reference = implode('.', $e);
$alias = $this->query->getTableAlias($reference); $alias = $this->query->getTableAlias($reference);
$table = $this->query->getTable($alias);
$result[] = $table->getColumnName($field) . ' = ' . $set[1]; $map = $this->query->getDeclaration($reference);
$result[] = $map['table']->getColumnName($field) . ' = ' . $set[1];
} }
return implode(', ', $result); $this->query->addQueryPart('set', implode(', ', $result));
return $this->query;
} }
} }
...@@ -32,6 +32,15 @@ Doctrine::autoload('Doctrine_Query_Condition'); ...@@ -32,6 +32,15 @@ Doctrine::autoload('Doctrine_Query_Condition');
*/ */
class Doctrine_Query_Where extends Doctrine_Query_Condition class Doctrine_Query_Where extends Doctrine_Query_Condition
{ {
public function parse($str, $append = false)
{
if ($append) {
$this->query->addQueryPart('where', $this->_parse($str));
} else {
$this->query->setQueryPart('where', $this->_parse($str));
}
return $this->query;
}
/** /**
* load * load
* returns the parsed query part * returns the parsed query part
...@@ -43,7 +52,7 @@ class Doctrine_Query_Where extends Doctrine_Query_Condition ...@@ -43,7 +52,7 @@ class Doctrine_Query_Where extends Doctrine_Query_Condition
{ {
$where = trim($where); $where = trim($where);
$e = Doctrine_Query::sqlExplode($where); $e = Doctrine_Tokenizer::sqlExplode($where);
if (count($e) > 1) { if (count($e) > 1) {
$tmp = $e[0] . ' ' . $e[1]; $tmp = $e[0] . ' ' . $e[1];
...@@ -56,7 +65,7 @@ class Doctrine_Query_Where extends Doctrine_Query_Condition ...@@ -56,7 +65,7 @@ class Doctrine_Query_Where extends Doctrine_Query_Condition
} }
if (count($e) < 3) { if (count($e) < 3) {
$e = Doctrine_Query::sqlExplode($where, array('=', '<', '>', '!=')); $e = Doctrine_Tokenizer::sqlExplode($where, array('=', '<', '>', '!='));
} }
$r = array_shift($e); $r = array_shift($e);
...@@ -83,7 +92,6 @@ class Doctrine_Query_Where extends Doctrine_Query_Condition ...@@ -83,7 +92,6 @@ class Doctrine_Query_Where extends Doctrine_Query_Condition
$field = array_pop($a); $field = array_pop($a);
$reference = implode('.', $a); $reference = implode('.', $a);
$table = $this->query->load($reference, false); $table = $this->query->load($reference, false);
$field = $table->getColumnName($field); $field = $table->getColumnName($field);
array_pop($a); array_pop($a);
...@@ -119,20 +127,20 @@ class Doctrine_Query_Where extends Doctrine_Query_Condition ...@@ -119,20 +127,20 @@ class Doctrine_Query_Where extends Doctrine_Query_Condition
throw new Doctrine_Query_Exception('Unknown DQL function: '.$func); throw new Doctrine_Query_Exception('Unknown DQL function: '.$func);
} }
} else { } else {
$table = $this->query->load($reference, false); $map = $this->query->load($reference, false);
$alias = $this->query->getTableAlias($reference);
$table = $this->query->getTable($alias); $alias = $this->query->getTableAlias($reference);
$table = $map['table'];
$field = $table->getColumnName($field);
$field = $table->getColumnName($field);
// check if value is enumerated value // check if value is enumerated value
$enumIndex = $table->enumIndex($field, trim($value, "'")); $enumIndex = $table->enumIndex($field, trim($value, "'"));
if (substr($value, 0, 1) == '(') { if (substr($value, 0, 1) == '(') {
// trim brackets // trim brackets
$trimmed = Doctrine_Query::bracketTrim($value); $trimmed = Doctrine_Tokenizer::bracketTrim($value);
if (substr($trimmed, 0, 4) == 'FROM' || substr($trimmed, 0, 6) == 'SELECT') { if (substr($trimmed, 0, 4) == 'FROM' || substr($trimmed, 0, 6) == 'SELECT') {
// subquery found // subquery found
$q = new Doctrine_Query(); $q = new Doctrine_Query();
$value = '(' . $q->isSubquery(true)->parseQuery($trimmed)->getQuery() . ')'; $value = '(' . $q->isSubquery(true)->parseQuery($trimmed)->getQuery() . ')';
...@@ -141,11 +149,12 @@ class Doctrine_Query_Where extends Doctrine_Query_Condition ...@@ -141,11 +149,12 @@ class Doctrine_Query_Where extends Doctrine_Query_Condition
$value = '(' . substr($trimmed, 4) . ')'; $value = '(' . substr($trimmed, 4) . ')';
} else { } else {
// simple in expression found // simple in expression found
$e = Doctrine_Query::sqlExplode($trimmed, ','); $e = Doctrine_Tokenizer::sqlExplode($trimmed, ',');
$value = array(); $value = array();
foreach ($e as $part) { foreach ($e as $part) {
$index = $table->enumIndex($field, trim($part, "'")); $index = $table->enumIndex($field, trim($part, "'"));
if ($index !== false) { if ($index !== false) {
$value[] = $index; $value[] = $index;
} else { } else {
...@@ -198,10 +207,11 @@ class Doctrine_Query_Where extends Doctrine_Query_Condition ...@@ -198,10 +207,11 @@ class Doctrine_Query_Where extends Doctrine_Query_Condition
$pos = strpos($where, '('); $pos = strpos($where, '(');
if ($pos == false) if ($pos == false) {
throw new Doctrine_Query_Exception("Unknown expression, expected '('"); throw new Doctrine_Query_Exception("Unknown expression, expected '('");
}
$sub = Doctrine_Query::bracketTrim(substr($where, $pos)); $sub = Doctrine_Tokenizer::bracketTrim(substr($where, $pos));
return $operator . ' (' . $this->query->createSubquery()->parseQuery($sub, false)->getQuery() . ')'; return $operator . ' (' . $this->query->createSubquery()->parseQuery($sub, false)->getQuery() . ')';
} }
...@@ -226,14 +236,4 @@ class Doctrine_Query_Where extends Doctrine_Query_Condition ...@@ -226,14 +236,4 @@ class Doctrine_Query_Where extends Doctrine_Query_Condition
} }
return $operator; return $operator;
} }
/**
* __toString
* return string representation of this object
*
* @return string
*/
public function __toString()
{
return ( ! empty($this->parts))?implode(' AND ', $this->parts):'';
}
} }
...@@ -53,7 +53,7 @@ class Doctrine_Record_Filter ...@@ -53,7 +53,7 @@ class Doctrine_Record_Filter
*/ */
public function getRecord() public function getRecord()
{ {
return $this->_record; return $this->_record;
} }
/** /**
* cleanData * cleanData
...@@ -100,8 +100,9 @@ class Doctrine_Record_Filter ...@@ -100,8 +100,9 @@ class Doctrine_Record_Filter
if (is_string($tmp[$name])) { if (is_string($tmp[$name])) {
$value = unserialize($tmp[$name]); $value = unserialize($tmp[$name]);
if ($value === false) if ($value === false) {
throw new Doctrine_Record_Exception('Unserialization of ' . $name . ' failed.'); throw new Doctrine_Record_Exception('Unserialization of ' . $name . ' failed.');
}
} else { } else {
$value = $tmp[$name]; $value = $tmp[$name];
} }
...@@ -112,9 +113,10 @@ class Doctrine_Record_Filter ...@@ -112,9 +113,10 @@ class Doctrine_Record_Filter
if ($tmp[$name] !== self::$null) { if ($tmp[$name] !== self::$null) {
$value = gzuncompress($tmp[$name]); $value = gzuncompress($tmp[$name]);
if ($value === false) if ($value === false) {
throw new Doctrine_Record_Exception('Uncompressing of ' . $name . ' failed.'); throw new Doctrine_Record_Exception('Uncompressing of ' . $name . ' failed.');
}
$this->_data[$name] = $value; $this->_data[$name] = $value;
} }
break; break;
...@@ -212,8 +214,9 @@ class Doctrine_Record_Filter ...@@ -212,8 +214,9 @@ class Doctrine_Record_Filter
$a[$v] = $this->_table->enumIndex($v,$this->_data[$v]); $a[$v] = $this->_table->enumIndex($v,$this->_data[$v]);
break; break;
default: default:
if ($this->_data[$v] instanceof Doctrine_Record) if ($this->_data[$v] instanceof Doctrine_Record) {
$this->_data[$v] = $this->_data[$v]->getIncremented(); $this->_data[$v] = $this->_data[$v]->getIncremented();
}
$a[$v] = $this->_data[$v]; $a[$v] = $this->_data[$v];
} }
......
...@@ -126,7 +126,7 @@ class Doctrine_Relation_Association extends Doctrine_Relation ...@@ -126,7 +126,7 @@ class Doctrine_Relation_Association extends Doctrine_Relation
*/ */
public function fetchRelatedFor(Doctrine_Record $record) public function fetchRelatedFor(Doctrine_Record $record)
{ {
$id = $record->getIncremented(); $id = $record->getIncremented();
if (empty($id)) { if (empty($id)) {
$coll = new Doctrine_Collection($this->getTable()); $coll = new Doctrine_Collection($this->getTable());
} else { } else {
......
...@@ -792,7 +792,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable ...@@ -792,7 +792,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
$alias = $name; $alias = $name;
} }
$this->bound[$alias] = array('field' => $field, $this->bound[$alias] = array('field' => $field,
'type' => $type, 'type' => $type,
'class' => $name, 'class' => $name,
'alias' => $alias); 'alias' => $alias);
...@@ -1125,32 +1125,38 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable ...@@ -1125,32 +1125,38 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
*/ */
public function getRecord() public function getRecord()
{ {
$this->data = array_change_key_case($this->data, CASE_LOWER); if ( ! empty($this->data)) {
$this->data = array_change_key_case($this->data, CASE_LOWER);
$key = $this->getIdentifier();
$key = $this->getIdentifier();
if ( ! is_array($key)) {
$key = array($key); if ( ! is_array($key)) {
} $key = array($key);
foreach ($key as $k) {
if ( ! isset($this->data[$k])) {
throw new Doctrine_Table_Exception("Primary key value for $k wasn't found");
} }
$id[] = $this->data[$k];
} foreach ($key as $k) {
if ( ! isset($this->data[$k])) {
$id = implode(' ', $id); throw new Doctrine_Table_Exception("Primary key value for $k wasn't found");
}
if (isset($this->identityMap[$id])) { $id[] = $this->data[$k];
$record = $this->identityMap[$id]; }
$record->hydrate($this->data);
$id = implode(' ', $id);
if (isset($this->identityMap[$id])) {
$record = $this->identityMap[$id];
$record->hydrate($this->data);
} else {
$recordName = $this->getClassnameToReturn();
$record = new $recordName($this);
$this->identityMap[$id] = $record;
}
$this->data = array();
} else { } else {
$recordName = $this->getClassnameToReturn(); $recordName = $this->getClassnameToReturn();
$record = new $recordName($this); $record = new $recordName($this, true);
$this->identityMap[$id] = $record;
} }
$this->data = array();
return $record; return $record;
} }
......
...@@ -111,7 +111,7 @@ class Doctrine_Hydrate_TestCase extends Doctrine_UnitTestCase ...@@ -111,7 +111,7 @@ class Doctrine_Hydrate_TestCase extends Doctrine_UnitTestCase
} }
*/ */
} }
class Doctrine_Hydrate_Mock extends Doctrine_Hydrate2 class Doctrine_Hydrate_Mock extends Doctrine_Hydrate
{ {
protected $data; protected $data;
......
...@@ -77,7 +77,7 @@ class Doctrine_Query_AggregateValue_TestCase extends Doctrine_UnitTestCase ...@@ -77,7 +77,7 @@ class Doctrine_Query_AggregateValue_TestCase extends Doctrine_UnitTestCase
} }
public function testAggregateValueIsMappedToNewRecordOnEmptyResultSet() public function testAggregateValueIsMappedToNewRecordOnEmptyResultSet()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->select('COUNT(u.id) count')->from('User u'); $q->select('COUNT(u.id) count')->from('User u');
...@@ -88,7 +88,7 @@ class Doctrine_Query_AggregateValue_TestCase extends Doctrine_UnitTestCase ...@@ -88,7 +88,7 @@ class Doctrine_Query_AggregateValue_TestCase extends Doctrine_UnitTestCase
} }
public function testAggregateValueIsMappedToRecord() public function testAggregateValueIsMappedToRecord()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->select('u.name, COUNT(u.id) count')->from('User u')->groupby('u.name'); $q->select('u.name, COUNT(u.id) count')->from('User u')->groupby('u.name');
...@@ -105,7 +105,7 @@ class Doctrine_Query_AggregateValue_TestCase extends Doctrine_UnitTestCase ...@@ -105,7 +105,7 @@ class Doctrine_Query_AggregateValue_TestCase extends Doctrine_UnitTestCase
public function testAggregateValueMappingSupportsLeftJoins() public function testAggregateValueMappingSupportsLeftJoins()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->select('u.name, COUNT(p.id) count')->from('User u')->leftJoin('u.Phonenumber p')->groupby('u.id'); $q->select('u.name, COUNT(p.id) count')->from('User u')->leftJoin('u.Phonenumber p')->groupby('u.id');
...@@ -120,7 +120,7 @@ class Doctrine_Query_AggregateValue_TestCase extends Doctrine_UnitTestCase ...@@ -120,7 +120,7 @@ class Doctrine_Query_AggregateValue_TestCase extends Doctrine_UnitTestCase
} }
public function testAggregateValueMappingSupportsLeftJoins2() public function testAggregateValueMappingSupportsLeftJoins2()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->select('MAX(u.name)')->from('User u')->leftJoin('u.Phonenumber p')->groupby('u.id'); $q->select('MAX(u.name)')->from('User u')->leftJoin('u.Phonenumber p')->groupby('u.id');
...@@ -131,7 +131,7 @@ class Doctrine_Query_AggregateValue_TestCase extends Doctrine_UnitTestCase ...@@ -131,7 +131,7 @@ class Doctrine_Query_AggregateValue_TestCase extends Doctrine_UnitTestCase
} }
public function testAggregateValueMappingSupportsMultipleValues() public function testAggregateValueMappingSupportsMultipleValues()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->select('u.name, COUNT(p.id) count, MAX(p.id) max')->from('User u')->innerJoin('u.Phonenumber p')->groupby('u.id'); $q->select('u.name, COUNT(p.id) count, MAX(p.id) max')->from('User u')->innerJoin('u.Phonenumber p')->groupby('u.id');
...@@ -141,7 +141,7 @@ class Doctrine_Query_AggregateValue_TestCase extends Doctrine_UnitTestCase ...@@ -141,7 +141,7 @@ class Doctrine_Query_AggregateValue_TestCase extends Doctrine_UnitTestCase
} }
public function testAggregateValueMappingSupportsInnerJoins() public function testAggregateValueMappingSupportsInnerJoins()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->select('u.name, COUNT(p.id) count')->from('User u')->innerJoin('u.Phonenumber p')->groupby('u.id'); $q->select('u.name, COUNT(p.id) count')->from('User u')->innerJoin('u.Phonenumber p')->groupby('u.id');
......
...@@ -35,13 +35,13 @@ class Doctrine_Query_Delete_TestCase extends Doctrine_UnitTestCase ...@@ -35,13 +35,13 @@ class Doctrine_Query_Delete_TestCase extends Doctrine_UnitTestCase
{ {
public function testDeleteAllWithColumnAggregationInheritance() public function testDeleteAllWithColumnAggregationInheritance()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->parseQuery('DELETE FROM User'); $q->parseQuery('DELETE FROM User');
$this->assertEqual($q->getQuery(), 'DELETE FROM entity WHERE (type = 0)'); $this->assertEqual($q->getQuery(), 'DELETE FROM entity WHERE (type = 0)');
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->delete()->from('User'); $q->delete()->from('User');
...@@ -49,13 +49,13 @@ class Doctrine_Query_Delete_TestCase extends Doctrine_UnitTestCase ...@@ -49,13 +49,13 @@ class Doctrine_Query_Delete_TestCase extends Doctrine_UnitTestCase
} }
public function testDeleteAll() public function testDeleteAll()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->parseQuery('DELETE FROM Entity'); $q->parseQuery('DELETE FROM Entity');
$this->assertEqual($q->getQuery(), 'DELETE FROM entity'); $this->assertEqual($q->getQuery(), 'DELETE FROM entity');
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->delete()->from('Entity'); $q->delete()->from('Entity');
...@@ -63,13 +63,13 @@ class Doctrine_Query_Delete_TestCase extends Doctrine_UnitTestCase ...@@ -63,13 +63,13 @@ class Doctrine_Query_Delete_TestCase extends Doctrine_UnitTestCase
} }
public function testDeleteWithCondition() public function testDeleteWithCondition()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->parseQuery('DELETE FROM Entity WHERE id = 3'); $q->parseQuery('DELETE FROM Entity WHERE id = 3');
$this->assertEqual($q->getQuery(), 'DELETE FROM entity WHERE id = 3'); $this->assertEqual($q->getQuery(), 'DELETE FROM entity WHERE id = 3');
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->delete()->from('Entity')->where('id = 3'); $q->delete()->from('Entity')->where('id = 3');
...@@ -77,13 +77,13 @@ class Doctrine_Query_Delete_TestCase extends Doctrine_UnitTestCase ...@@ -77,13 +77,13 @@ class Doctrine_Query_Delete_TestCase extends Doctrine_UnitTestCase
} }
public function testDeleteWithLimit() public function testDeleteWithLimit()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->parseQuery('DELETE FROM Entity LIMIT 20'); $q->parseQuery('DELETE FROM Entity LIMIT 20');
$this->assertEqual($q->getQuery(), 'DELETE FROM entity LIMIT 20'); $this->assertEqual($q->getQuery(), 'DELETE FROM entity LIMIT 20');
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->delete()->from('Entity')->limit(20); $q->delete()->from('Entity')->limit(20);
...@@ -91,13 +91,13 @@ class Doctrine_Query_Delete_TestCase extends Doctrine_UnitTestCase ...@@ -91,13 +91,13 @@ class Doctrine_Query_Delete_TestCase extends Doctrine_UnitTestCase
} }
public function testDeleteWithLimitAndOffset() public function testDeleteWithLimitAndOffset()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->parseQuery('DELETE FROM Entity LIMIT 10 OFFSET 20'); $q->parseQuery('DELETE FROM Entity LIMIT 10 OFFSET 20');
$this->assertEqual($q->getQuery(), 'DELETE FROM entity LIMIT 10 OFFSET 20'); $this->assertEqual($q->getQuery(), 'DELETE FROM entity LIMIT 10 OFFSET 20');
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->delete()->from('Entity')->limit(10)->offset(20); $q->delete()->from('Entity')->limit(10)->offset(20);
......
...@@ -34,7 +34,7 @@ class Doctrine_Query_From_TestCase extends Doctrine_UnitTestCase ...@@ -34,7 +34,7 @@ class Doctrine_Query_From_TestCase extends Doctrine_UnitTestCase
{ {
public function testLeftJoin() public function testLeftJoin()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->from('User u LEFT JOIN u.Group'); $q->from('User u LEFT JOIN u.Group');
...@@ -43,7 +43,7 @@ class Doctrine_Query_From_TestCase extends Doctrine_UnitTestCase ...@@ -43,7 +43,7 @@ class Doctrine_Query_From_TestCase extends Doctrine_UnitTestCase
public function testDefaultJoinIsLeftJoin() public function testDefaultJoinIsLeftJoin()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->from('User u JOIN u.Group'); $q->from('User u JOIN u.Group');
...@@ -52,7 +52,7 @@ class Doctrine_Query_From_TestCase extends Doctrine_UnitTestCase ...@@ -52,7 +52,7 @@ class Doctrine_Query_From_TestCase extends Doctrine_UnitTestCase
public function testInnerJoin() public function testInnerJoin()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->from('User u INNER JOIN u.Group'); $q->from('User u INNER JOIN u.Group');
...@@ -61,7 +61,7 @@ class Doctrine_Query_From_TestCase extends Doctrine_UnitTestCase ...@@ -61,7 +61,7 @@ class Doctrine_Query_From_TestCase extends Doctrine_UnitTestCase
public function testMultipleLeftJoin() public function testMultipleLeftJoin()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->from('User u LEFT JOIN u.Group LEFT JOIN u.Phonenumber'); $q->from('User u LEFT JOIN u.Group LEFT JOIN u.Phonenumber');
...@@ -69,7 +69,7 @@ class Doctrine_Query_From_TestCase extends Doctrine_UnitTestCase ...@@ -69,7 +69,7 @@ class Doctrine_Query_From_TestCase extends Doctrine_UnitTestCase
} }
public function testMultipleLeftJoin2() public function testMultipleLeftJoin2()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->from('User u LEFT JOIN u.Group LEFT JOIN u.Phonenumber'); $q->from('User u LEFT JOIN u.Group LEFT JOIN u.Phonenumber');
...@@ -77,7 +77,7 @@ class Doctrine_Query_From_TestCase extends Doctrine_UnitTestCase ...@@ -77,7 +77,7 @@ class Doctrine_Query_From_TestCase extends Doctrine_UnitTestCase
} }
public function testMultipleInnerJoin() public function testMultipleInnerJoin()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->select('u.name')->from('User u INNER JOIN u.Group INNER JOIN u.Phonenumber'); $q->select('u.name')->from('User u INNER JOIN u.Group INNER JOIN u.Phonenumber');
...@@ -85,7 +85,7 @@ class Doctrine_Query_From_TestCase extends Doctrine_UnitTestCase ...@@ -85,7 +85,7 @@ class Doctrine_Query_From_TestCase extends Doctrine_UnitTestCase
} }
public function testMultipleInnerJoin2() public function testMultipleInnerJoin2()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->select('u.name')->from('User u INNER JOIN u.Group, u.Phonenumber'); $q->select('u.name')->from('User u INNER JOIN u.Group, u.Phonenumber');
...@@ -97,7 +97,7 @@ class Doctrine_Query_From_TestCase extends Doctrine_UnitTestCase ...@@ -97,7 +97,7 @@ class Doctrine_Query_From_TestCase extends Doctrine_UnitTestCase
} }
public function testMixingOfJoins() public function testMixingOfJoins()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->select('u.name, g.name, p.phonenumber')->from('User u INNER JOIN u.Group g LEFT JOIN u.Phonenumber p'); $q->select('u.name, g.name, p.phonenumber')->from('User u INNER JOIN u.Group g LEFT JOIN u.Phonenumber p');
......
...@@ -32,14 +32,14 @@ ...@@ -32,14 +32,14 @@
*/ */
class Doctrine_Query_Having_TestCase extends Doctrine_UnitTestCase { class Doctrine_Query_Having_TestCase extends Doctrine_UnitTestCase {
public function testAggregateFunctionsInHavingReturnValidSql() { public function testAggregateFunctionsInHavingReturnValidSql() {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->parseQuery('SELECT u.name FROM User u LEFT JOIN u.Phonenumber p HAVING COUNT(p.id) > 2'); $q->parseQuery('SELECT u.name FROM User u LEFT JOIN u.Phonenumber p HAVING COUNT(p.id) > 2');
$this->assertEqual($q->getQuery(), 'SELECT e.id AS e__id, e.name AS e__name FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE (e.type = 0) HAVING COUNT(p.id) > 2'); $this->assertEqual($q->getQuery(), 'SELECT e.id AS e__id, e.name AS e__name FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE (e.type = 0) HAVING COUNT(p.id) > 2');
} }
public function testAggregateFunctionsInHavingReturnValidSql2() { public function testAggregateFunctionsInHavingReturnValidSql2() {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->parseQuery("SELECT u.name FROM User u LEFT JOIN u.Phonenumber p HAVING MAX(u.name) = 'zYne'"); $q->parseQuery("SELECT u.name FROM User u LEFT JOIN u.Phonenumber p HAVING MAX(u.name) = 'zYne'");
......
...@@ -39,7 +39,7 @@ class Doctrine_Query_IdentifierQuoting_TestCase extends Doctrine_UnitTestCase { ...@@ -39,7 +39,7 @@ class Doctrine_Query_IdentifierQuoting_TestCase extends Doctrine_UnitTestCase {
public function testQuerySupportsIdentifierQuoting() { public function testQuerySupportsIdentifierQuoting() {
$this->connection->setAttribute(Doctrine::ATTR_QUOTE_IDENTIFIER, true); $this->connection->setAttribute(Doctrine::ATTR_QUOTE_IDENTIFIER, true);
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->parseQuery('SELECT MAX(u.id), MIN(u.name) FROM User u'); $q->parseQuery('SELECT MAX(u.id), MIN(u.name) FROM User u');
...@@ -47,7 +47,7 @@ class Doctrine_Query_IdentifierQuoting_TestCase extends Doctrine_UnitTestCase { ...@@ -47,7 +47,7 @@ class Doctrine_Query_IdentifierQuoting_TestCase extends Doctrine_UnitTestCase {
} }
public function testQuerySupportsIdentifierQuotingWithJoins() { public function testQuerySupportsIdentifierQuotingWithJoins() {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->parseQuery('SELECT u.name FROM User u LEFT JOIN u.Phonenumber p'); $q->parseQuery('SELECT u.name FROM User u LEFT JOIN u.Phonenumber p');
...@@ -55,7 +55,7 @@ class Doctrine_Query_IdentifierQuoting_TestCase extends Doctrine_UnitTestCase { ...@@ -55,7 +55,7 @@ class Doctrine_Query_IdentifierQuoting_TestCase extends Doctrine_UnitTestCase {
} }
public function testLimitSubqueryAlgorithmSupportsIdentifierQuoting() { public function testLimitSubqueryAlgorithmSupportsIdentifierQuoting() {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->parseQuery('SELECT u.name FROM User u INNER JOIN u.Phonenumber p')->limit(5); $q->parseQuery('SELECT u.name FROM User u INNER JOIN u.Phonenumber p')->limit(5);
......
...@@ -38,7 +38,7 @@ class Doctrine_Query_JoinCondition_TestCase extends Doctrine_UnitTestCase ...@@ -38,7 +38,7 @@ class Doctrine_Query_JoinCondition_TestCase extends Doctrine_UnitTestCase
{ } { }
public function testJoinConditionsAreSupportedForOneToManyLeftJoins() public function testJoinConditionsAreSupportedForOneToManyLeftJoins()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->parseQuery("SELECT u.name, p.id FROM User u LEFT JOIN u.Phonenumber p ON p.phonenumber = '123 123'"); $q->parseQuery("SELECT u.name, p.id FROM User u LEFT JOIN u.Phonenumber p ON p.phonenumber = '123 123'");
...@@ -46,7 +46,7 @@ class Doctrine_Query_JoinCondition_TestCase extends Doctrine_UnitTestCase ...@@ -46,7 +46,7 @@ class Doctrine_Query_JoinCondition_TestCase extends Doctrine_UnitTestCase
} }
public function testJoinConditionsAreSupportedForOneToManyInnerJoins() public function testJoinConditionsAreSupportedForOneToManyInnerJoins()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->parseQuery("SELECT u.name, p.id FROM User u INNER JOIN u.Phonenumber p ON p.phonenumber = '123 123'"); $q->parseQuery("SELECT u.name, p.id FROM User u INNER JOIN u.Phonenumber p ON p.phonenumber = '123 123'");
...@@ -54,7 +54,7 @@ class Doctrine_Query_JoinCondition_TestCase extends Doctrine_UnitTestCase ...@@ -54,7 +54,7 @@ class Doctrine_Query_JoinCondition_TestCase extends Doctrine_UnitTestCase
} }
public function testJoinConditionsAreSupportedForManyToManyLeftJoins() public function testJoinConditionsAreSupportedForManyToManyLeftJoins()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->parseQuery("SELECT u.name, g.id FROM User u LEFT JOIN u.Group g ON g.id > 2"); $q->parseQuery("SELECT u.name, g.id FROM User u LEFT JOIN u.Group g ON g.id > 2");
...@@ -62,7 +62,7 @@ class Doctrine_Query_JoinCondition_TestCase extends Doctrine_UnitTestCase ...@@ -62,7 +62,7 @@ class Doctrine_Query_JoinCondition_TestCase extends Doctrine_UnitTestCase
} }
public function testJoinConditionsAreSupportedForManyToManyInnerJoins() public function testJoinConditionsAreSupportedForManyToManyInnerJoins()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->parseQuery("SELECT u.name, g.id FROM User u INNER JOIN u.Group g ON g.id > 2"); $q->parseQuery("SELECT u.name, g.id FROM User u INNER JOIN u.Group g ON g.id > 2");
......
...@@ -58,7 +58,7 @@ class Doctrine_Query_Join_TestCase extends Doctrine_UnitTestCase ...@@ -58,7 +58,7 @@ class Doctrine_Query_Join_TestCase extends Doctrine_UnitTestCase
} }
public function testRecordHydrationWorksWithDeeplyNestedStructures() public function testRecordHydrationWorksWithDeeplyNestedStructures()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->select('c.*, c2.*, d.*') $q->select('c.*, c2.*, d.*')
->from('Record_Country c')->leftJoin('c.City c2')->leftJoin('c2.District d') ->from('Record_Country c')->leftJoin('c.City c2')->leftJoin('c2.District d')
...@@ -77,7 +77,7 @@ class Doctrine_Query_Join_TestCase extends Doctrine_UnitTestCase ...@@ -77,7 +77,7 @@ class Doctrine_Query_Join_TestCase extends Doctrine_UnitTestCase
} }
public function testManyToManyJoinUsesProperTableAliases() public function testManyToManyJoinUsesProperTableAliases()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->select('u.name')->from('User u INNER JOIN u.Group g'); $q->select('u.name')->from('User u INNER JOIN u.Group g');
...@@ -86,7 +86,7 @@ class Doctrine_Query_Join_TestCase extends Doctrine_UnitTestCase ...@@ -86,7 +86,7 @@ class Doctrine_Query_Join_TestCase extends Doctrine_UnitTestCase
public function testSelfReferentialAssociationJoinsAreSupported() public function testSelfReferentialAssociationJoinsAreSupported()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->select('e.name')->from('Entity e INNER JOIN e.Entity e2'); $q->select('e.name')->from('Entity e INNER JOIN e.Entity e2');
......
...@@ -45,7 +45,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase ...@@ -45,7 +45,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase
public function testLimitWithOneToOneLeftJoin() public function testLimitWithOneToOneLeftJoin()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->select('u.id, e.*')->from('User u, u.Email e')->limit(5); $q->select('u.id, e.*')->from('User u, u.Email e')->limit(5);
$users = $q->execute(); $users = $q->execute();
...@@ -55,7 +55,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase ...@@ -55,7 +55,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase
} }
public function testLimitWithOneToOneInnerJoin() public function testLimitWithOneToOneInnerJoin()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->select('u.id, e.*')->from('User u, u:Email e')->limit(5); $q->select('u.id, e.*')->from('User u, u:Email e')->limit(5);
$users = $q->execute(); $users = $q->execute();
...@@ -64,7 +64,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase ...@@ -64,7 +64,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase
} }
public function testLimitWithOneToManyLeftJoin() public function testLimitWithOneToManyLeftJoin()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->select('u.id, p.*')->from('User u, u.Phonenumber p')->limit(5); $q->select('u.id, p.*')->from('User u, u.Phonenumber p')->limit(5);
$sql = $q->getQuery(); $sql = $q->getQuery();
...@@ -91,7 +91,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase ...@@ -91,7 +91,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase
public function testLimitWithOneToManyLeftJoinAndCondition() public function testLimitWithOneToManyLeftJoinAndCondition()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->select('User.name')->from('User')->where("User.Phonenumber.phonenumber LIKE '%123%'")->limit(5); $q->select('User.name')->from('User')->where("User.Phonenumber.phonenumber LIKE '%123%'")->limit(5);
$users = $q->execute(); $users = $q->execute();
...@@ -111,7 +111,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase ...@@ -111,7 +111,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase
public function testLimitWithOneToManyLeftJoinAndOrderBy() public function testLimitWithOneToManyLeftJoinAndOrderBy()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->select('User.name')->from('User')->where("User.Phonenumber.phonenumber LIKE '%123%'")->orderby('User.Email.address')->limit(5); $q->select('User.name')->from('User')->where("User.Phonenumber.phonenumber LIKE '%123%'")->orderby('User.Email.address')->limit(5);
...@@ -128,7 +128,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase ...@@ -128,7 +128,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase
public function testLimitWithOneToManyInnerJoin() public function testLimitWithOneToManyInnerJoin()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->select('u.id, p.*')->from('User u INNER JOIN u.Phonenumber p'); $q->select('u.id, p.*')->from('User u INNER JOIN u.Phonenumber p');
$q->limit(5); $q->limit(5);
...@@ -156,7 +156,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase ...@@ -156,7 +156,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase
public function testLimitWithPreparedQueries() public function testLimitWithPreparedQueries()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->select('u.id, p.id')->from('User u LEFT JOIN u.Phonenumber p'); $q->select('u.id, p.id')->from('User u LEFT JOIN u.Phonenumber p');
$q->where('u.name = ?'); $q->where('u.name = ?');
$q->limit(5); $q->limit(5);
...@@ -170,7 +170,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase ...@@ -170,7 +170,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase
$this->assertEqual($q->getQuery(), $this->assertEqual($q->getQuery(),
'SELECT e.id AS e__id, p.id AS p__id FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE e.id IN (SELECT DISTINCT e2.id FROM entity e2 WHERE e2.name = ? AND (e2.type = 0) LIMIT 5) AND e.name = ? AND (e.type = 0)'); 'SELECT e.id AS e__id, p.id AS p__id FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE e.id IN (SELECT DISTINCT e2.id FROM entity e2 WHERE e2.name = ? AND (e2.type = 0) LIMIT 5) AND e.name = ? AND (e.type = 0)');
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->select('u.id, p.id')->from('User u LEFT JOIN u.Phonenumber p'); $q->select('u.id, p.id')->from('User u LEFT JOIN u.Phonenumber p');
$q->where("u.name LIKE ? || u.name LIKE ?"); $q->where("u.name LIKE ? || u.name LIKE ?");
$q->limit(5); $q->limit(5);
...@@ -188,7 +188,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase ...@@ -188,7 +188,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase
} }
public function testConnectionFlushing() public function testConnectionFlushing()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->from('User.Phonenumber'); $q->from('User.Phonenumber');
$q->where('User.name = ?'); $q->where('User.name = ?');
$q->limit(5); $q->limit(5);
...@@ -200,7 +200,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase ...@@ -200,7 +200,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase
} }
public function testLimitWithManyToManyColumnAggInheritanceLeftJoin() public function testLimitWithManyToManyColumnAggInheritanceLeftJoin()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->from('User.Group')->limit(5); $q->from('User.Group')->limit(5);
$users = $q->execute(); $users = $q->execute();
...@@ -227,7 +227,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase ...@@ -227,7 +227,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->from("User")->where("User.Group.id = ?")->orderby("User.id ASC")->limit(5); $q->from("User")->where("User.Group.id = ?")->orderby("User.id ASC")->limit(5);
...@@ -236,7 +236,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase ...@@ -236,7 +236,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase
$this->assertEqual($users->count(), 3); $this->assertEqual($users->count(), 3);
$this->connection->clear(); $this->connection->clear();
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->from('User')->where('User.Group.id = ?')->orderby('User.id DESC'); $q->from('User')->where('User.Group.id = ?')->orderby('User.id DESC');
$users = $q->execute(array($user->Group[1]->id)); $users = $q->execute(array($user->Group[1]->id));
...@@ -248,7 +248,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase ...@@ -248,7 +248,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase
$this->manager->setAttribute(Doctrine::ATTR_QUERY_LIMIT, Doctrine::LIMIT_ROWS); $this->manager->setAttribute(Doctrine::ATTR_QUERY_LIMIT, Doctrine::LIMIT_ROWS);
$this->connection->clear(); $this->connection->clear();
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->from("User")->where("User.Group.id = ?")->orderby("User.id DESC")->limit(5); $q->from("User")->where("User.Group.id = ?")->orderby("User.id DESC")->limit(5);
$users = $q->execute(array(3)); $users = $q->execute(array(3));
...@@ -260,7 +260,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase ...@@ -260,7 +260,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase
public function testLimitWithManyToManyAndColumnAggregationInheritance() public function testLimitWithManyToManyAndColumnAggregationInheritance()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->from('User u, u.Group g')->where('g.id > 1')->orderby('u.name DESC')->limit(10); $q->from('User u, u.Group g')->where('g.id > 1')->orderby('u.name DESC')->limit(10);
} }
...@@ -279,7 +279,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase ...@@ -279,7 +279,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase
$coll[3]->name = "photo 4"; $coll[3]->name = "photo 4";
$this->connection->flush(); $this->connection->flush();
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->from("Photo")->where("Photo.Tag.id = ?")->orderby("Photo.id DESC")->limit(100); $q->from("Photo")->where("Photo.Tag.id = ?")->orderby("Photo.id DESC")->limit(100);
$photos = $q->execute(array(1)); $photos = $q->execute(array(1));
......
...@@ -34,7 +34,7 @@ class Doctrine_Query_Orderby_TestCase extends Doctrine_UnitTestCase ...@@ -34,7 +34,7 @@ class Doctrine_Query_Orderby_TestCase extends Doctrine_UnitTestCase
{ {
public function testOrderByAggregateValueIsSupported() public function testOrderByAggregateValueIsSupported()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->select('u.name, COUNT(p.phonenumber) count') $q->select('u.name, COUNT(p.phonenumber) count')
->from('User u') ->from('User u')
...@@ -45,7 +45,7 @@ class Doctrine_Query_Orderby_TestCase extends Doctrine_UnitTestCase ...@@ -45,7 +45,7 @@ class Doctrine_Query_Orderby_TestCase extends Doctrine_UnitTestCase
} }
public function testOrderByRandomIsSupported() public function testOrderByRandomIsSupported()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->select('u.name, RANDOM() rand') $q->select('u.name, RANDOM() rand')
->from('User u') ->from('User u')
......
...@@ -34,7 +34,7 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase ...@@ -34,7 +34,7 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase
{ {
public function testAggregateFunctionWithDistinctKeyword() public function testAggregateFunctionWithDistinctKeyword()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->parseQuery('SELECT COUNT(DISTINCT u.name) FROM User u'); $q->parseQuery('SELECT COUNT(DISTINCT u.name) FROM User u');
...@@ -43,7 +43,7 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase ...@@ -43,7 +43,7 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase
public function testAggregateFunction() public function testAggregateFunction()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->parseQuery('SELECT COUNT(u.id) FROM User u'); $q->parseQuery('SELECT COUNT(u.id) FROM User u');
...@@ -52,7 +52,7 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase ...@@ -52,7 +52,7 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase
public function testSelectPartSupportsMultipleAggregateFunctions() public function testSelectPartSupportsMultipleAggregateFunctions()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->parseQuery('SELECT MAX(u.id), MIN(u.name) FROM User u'); $q->parseQuery('SELECT MAX(u.id), MIN(u.name) FROM User u');
...@@ -60,7 +60,7 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase ...@@ -60,7 +60,7 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase
} }
public function testMultipleAggregateFunctionsWithMultipleComponents() public function testMultipleAggregateFunctionsWithMultipleComponents()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->parseQuery('SELECT MAX(u.id), MIN(u.name), COUNT(p.id) FROM User u, u.Phonenumber p'); $q->parseQuery('SELECT MAX(u.id), MIN(u.name), COUNT(p.id) FROM User u, u.Phonenumber p');
...@@ -68,7 +68,7 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase ...@@ -68,7 +68,7 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase
} }
public function testEmptySelectPart() public function testEmptySelectPart()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
try { try {
$q->select(null); $q->select(null);
...@@ -80,7 +80,7 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase ...@@ -80,7 +80,7 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase
} }
public function testUnknownAggregateFunction() public function testUnknownAggregateFunction()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
try { try {
$q->parseQuery('SELECT UNKNOWN(u.id) FROM User'); $q->parseQuery('SELECT UNKNOWN(u.id) FROM User');
...@@ -91,7 +91,7 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase ...@@ -91,7 +91,7 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase
} }
public function testAggregateFunctionValueHydration() public function testAggregateFunctionValueHydration()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->parseQuery('SELECT u.id, COUNT(p.id) FROM User u, u.Phonenumber p GROUP BY u.id'); $q->parseQuery('SELECT u.id, COUNT(p.id) FROM User u, u.Phonenumber p GROUP BY u.id');
...@@ -107,7 +107,7 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase ...@@ -107,7 +107,7 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase
public function testSingleComponentWithAsterisk() public function testSingleComponentWithAsterisk()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->parseQuery('SELECT u.* FROM User u'); $q->parseQuery('SELECT u.* FROM User u');
...@@ -115,7 +115,7 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase ...@@ -115,7 +115,7 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase
} }
public function testSingleComponentWithMultipleColumns() public function testSingleComponentWithMultipleColumns()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->parseQuery('SELECT u.name, u.type FROM User u'); $q->parseQuery('SELECT u.name, u.type FROM User u');
...@@ -123,7 +123,7 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase ...@@ -123,7 +123,7 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase
} }
public function testMultipleComponentsWithAsterisk() public function testMultipleComponentsWithAsterisk()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->parseQuery('SELECT u.*, p.* FROM User u, u.Phonenumber p'); $q->parseQuery('SELECT u.*, p.* FROM User u, u.Phonenumber p');
...@@ -131,7 +131,7 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase ...@@ -131,7 +131,7 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase
} }
public function testMultipleComponentsWithMultipleColumns() public function testMultipleComponentsWithMultipleColumns()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->parseQuery('SELECT u.id, u.name, p.id FROM User u, u.Phonenumber p'); $q->parseQuery('SELECT u.id, u.name, p.id FROM User u, u.Phonenumber p');
...@@ -140,7 +140,7 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase ...@@ -140,7 +140,7 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase
public function testAggregateFunctionValueHydrationWithAliases() public function testAggregateFunctionValueHydrationWithAliases()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->parseQuery('SELECT u.id, COUNT(p.id) count FROM User u, u.Phonenumber p GROUP BY u.id'); $q->parseQuery('SELECT u.id, COUNT(p.id) count FROM User u, u.Phonenumber p GROUP BY u.id');
...@@ -154,7 +154,7 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase ...@@ -154,7 +154,7 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase
} }
public function testMultipleAggregateFunctionValueHydrationWithAliases() public function testMultipleAggregateFunctionValueHydrationWithAliases()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->parseQuery('SELECT u.id, COUNT(p.id) count, MAX(p.phonenumber) max FROM User u, u.Phonenumber p GROUP BY u.id'); $q->parseQuery('SELECT u.id, COUNT(p.id) count, MAX(p.phonenumber) max FROM User u, u.Phonenumber p GROUP BY u.id');
...@@ -175,7 +175,7 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase ...@@ -175,7 +175,7 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase
{ {
$this->connection->clear(); $this->connection->clear();
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->parseQuery('SELECT u.id, COUNT(p.id) count, MAX(p.phonenumber) max FROM User u, u.Phonenumber p GROUP BY u.id'); $q->parseQuery('SELECT u.id, COUNT(p.id) count, MAX(p.phonenumber) max FROM User u, u.Phonenumber p GROUP BY u.id');
......
...@@ -36,7 +36,7 @@ class Doctrine_Query_Subquery_TestCase extends Doctrine_UnitTestCase ...@@ -36,7 +36,7 @@ class Doctrine_Query_Subquery_TestCase extends Doctrine_UnitTestCase
public function testSubqueryWithWherePartAndInExpression() public function testSubqueryWithWherePartAndInExpression()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->from('User')->where("User.id NOT IN (SELECT User.id FROM User WHERE User.name = 'zYne')"); $q->from('User')->where("User.id NOT IN (SELECT User.id FROM User WHERE User.name = 'zYne')");
$this->assertEqual($q->getQuery(), $this->assertEqual($q->getQuery(),
...@@ -49,7 +49,7 @@ class Doctrine_Query_Subquery_TestCase extends Doctrine_UnitTestCase ...@@ -49,7 +49,7 @@ class Doctrine_Query_Subquery_TestCase extends Doctrine_UnitTestCase
} }
public function testSubqueryAllowsSelectingOfAnyField() public function testSubqueryAllowsSelectingOfAnyField()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->from('User u')->where('u.id NOT IN (SELECT g.user_id FROM Groupuser g)'); $q->from('User u')->where('u.id NOT IN (SELECT g.user_id FROM Groupuser g)');
$this->assertEqual($q->getQuery(), "SELECT e.id AS e__id, e.name AS e__name, e.loginname AS e__loginname, e.password AS e__password, e.type AS e__type, e.created AS e__created, e.updated AS e__updated, e.email_id AS e__email_id FROM entity e WHERE e.id NOT IN (SELECT g.user_id AS g__user_id FROM groupuser g) AND (e.type = 0)"); $this->assertEqual($q->getQuery(), "SELECT e.id AS e__id, e.name AS e__name, e.loginname AS e__loginname, e.password AS e__password, e.type AS e__type, e.created AS e__created, e.updated AS e__updated, e.email_id AS e__email_id FROM entity e WHERE e.id NOT IN (SELECT g.user_id AS g__user_id FROM groupuser g) AND (e.type = 0)");
...@@ -58,7 +58,7 @@ class Doctrine_Query_Subquery_TestCase extends Doctrine_UnitTestCase ...@@ -58,7 +58,7 @@ class Doctrine_Query_Subquery_TestCase extends Doctrine_UnitTestCase
public function testSubqueryInSelectPart() public function testSubqueryInSelectPart()
{ {
// ticket #307 // ticket #307
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->parseQuery("SELECT u.name, (SELECT COUNT(p.id) FROM Phonenumber p WHERE p.entity_id = u.id) pcount FROM User u WHERE u.name = 'zYne' LIMIT 1"); $q->parseQuery("SELECT u.name, (SELECT COUNT(p.id) FROM Phonenumber p WHERE p.entity_id = u.id) pcount FROM User u WHERE u.name = 'zYne' LIMIT 1");
...@@ -77,7 +77,7 @@ class Doctrine_Query_Subquery_TestCase extends Doctrine_UnitTestCase ...@@ -77,7 +77,7 @@ class Doctrine_Query_Subquery_TestCase extends Doctrine_UnitTestCase
public function testSubqueryInSelectPart2() public function testSubqueryInSelectPart2()
{ {
// ticket #307 // ticket #307
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->parseQuery("SELECT u.name, (SELECT COUNT(w.id) FROM User w WHERE w.id = u.id) pcount FROM User u WHERE u.name = 'zYne' LIMIT 1"); $q->parseQuery("SELECT u.name, (SELECT COUNT(w.id) FROM User w WHERE w.id = u.id) pcount FROM User u WHERE u.name = 'zYne' LIMIT 1");
......
...@@ -35,13 +35,13 @@ class Doctrine_Query_Update_TestCase extends Doctrine_UnitTestCase ...@@ -35,13 +35,13 @@ class Doctrine_Query_Update_TestCase extends Doctrine_UnitTestCase
{ {
public function testUpdateAllWithColumnAggregationInheritance() public function testUpdateAllWithColumnAggregationInheritance()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->parseQuery("UPDATE User u SET u.name = 'someone'"); $q->parseQuery("UPDATE User u SET u.name = 'someone'");
$this->assertEqual($q->getQuery(), "UPDATE entity SET name = 'someone' WHERE (type = 0)"); $this->assertEqual($q->getQuery(), "UPDATE entity SET name = 'someone' WHERE (type = 0)");
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->update('User u')->set('u.name', "'someone'"); $q->update('User u')->set('u.name', "'someone'");
...@@ -49,13 +49,13 @@ class Doctrine_Query_Update_TestCase extends Doctrine_UnitTestCase ...@@ -49,13 +49,13 @@ class Doctrine_Query_Update_TestCase extends Doctrine_UnitTestCase
} }
public function testUpdateWorksWithMultipleColumns() public function testUpdateWorksWithMultipleColumns()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->parseQuery("UPDATE User u SET u.name = 'someone', u.email_id = 5"); $q->parseQuery("UPDATE User u SET u.name = 'someone', u.email_id = 5");
$this->assertEqual($q->getQuery(), "UPDATE entity SET name = 'someone', email_id = 5 WHERE (type = 0)"); $this->assertEqual($q->getQuery(), "UPDATE entity SET name = 'someone', email_id = 5 WHERE (type = 0)");
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->update('User u')->set('u.name', "'someone'")->set('u.email_id', 5); $q->update('User u')->set('u.name', "'someone'")->set('u.email_id', 5);
...@@ -63,7 +63,7 @@ class Doctrine_Query_Update_TestCase extends Doctrine_UnitTestCase ...@@ -63,7 +63,7 @@ class Doctrine_Query_Update_TestCase extends Doctrine_UnitTestCase
} }
public function testUpdateSupportsConditions() public function testUpdateSupportsConditions()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->parseQuery("UPDATE User u SET u.name = 'someone' WHERE u.id = 5"); $q->parseQuery("UPDATE User u SET u.name = 'someone' WHERE u.id = 5");
......
...@@ -47,7 +47,7 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase ...@@ -47,7 +47,7 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase
$user->name = 'someone'; $user->name = 'someone';
$user->save(); $user->save();
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->from('User')->addWhere('User.id = ?',1); $q->from('User')->addWhere('User.id = ?',1);
...@@ -63,7 +63,7 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase ...@@ -63,7 +63,7 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase
$user->name = 'someone.2'; $user->name = 'someone.2';
$user->save(); $user->save();
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->from('User')->addWhere('User.id IN (?, ?)', array(1, 2)); $q->from('User')->addWhere('User.id IN (?, ?)', array(1, 2));
...@@ -75,7 +75,7 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase ...@@ -75,7 +75,7 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase
} }
public function testDirectMultipleParameterSetting2() public function testDirectMultipleParameterSetting2()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->from('User')->where('User.id IN (?, ?)', array(1, 2)); $q->from('User')->where('User.id IN (?, ?)', array(1, 2));
...@@ -98,7 +98,7 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase ...@@ -98,7 +98,7 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase
} }
public function testNotInExpression() public function testNotInExpression()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->from('User u')->addWhere('u.id NOT IN (?)', array(1)); $q->from('User u')->addWhere('u.id NOT IN (?)', array(1));
$users = $q->execute(); $users = $q->execute();
...@@ -108,7 +108,7 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase ...@@ -108,7 +108,7 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase
} }
public function testExistsExpression() public function testExistsExpression()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$user = new User(); $user = new User();
$user->name = 'someone with a group'; $user->name = 'someone with a group';
...@@ -129,7 +129,7 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase ...@@ -129,7 +129,7 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase
public function testNotExistsExpression() public function testNotExistsExpression()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
// find all users which don't have groups // find all users which don't have groups
try { try {
...@@ -145,7 +145,7 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase ...@@ -145,7 +145,7 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase
} }
public function testComponentAliases() public function testComponentAliases()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->from('User u')->addWhere('u.id IN (?, ?)', array(1,2)); $q->from('User u')->addWhere('u.id IN (?, ?)', array(1,2));
...@@ -158,7 +158,7 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase ...@@ -158,7 +158,7 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase
} }
public function testComponentAliases2() public function testComponentAliases2()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->from('User u')->addWhere('u.name = ?', array('someone')); $q->from('User u')->addWhere('u.name = ?', array('someone'));
...@@ -169,7 +169,7 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase ...@@ -169,7 +169,7 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase
} }
public function testOperatorWithNoTrailingSpaces() public function testOperatorWithNoTrailingSpaces()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->select('User.id')->from('User')->where("User.name='someone'"); $q->select('User.id')->from('User')->where("User.name='someone'");
...@@ -180,7 +180,7 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase ...@@ -180,7 +180,7 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase
} }
public function testOperatorWithNoTrailingSpaces2() public function testOperatorWithNoTrailingSpaces2()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->select('User.id')->from('User')->where("User.name='foo.bar'"); $q->select('User.id')->from('User')->where("User.name='foo.bar'");
...@@ -191,7 +191,7 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase ...@@ -191,7 +191,7 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase
} }
public function testOperatorWithSingleTrailingSpace() public function testOperatorWithSingleTrailingSpace()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->select('User.id')->from('User')->where("User.name= 'foo.bar'"); $q->select('User.id')->from('User')->where("User.name= 'foo.bar'");
...@@ -202,7 +202,7 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase ...@@ -202,7 +202,7 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase
} }
public function testOperatorWithSingleTrailingSpace2() public function testOperatorWithSingleTrailingSpace2()
{ {
$q = new Doctrine_Query2(); $q = new Doctrine_Query();
$q->select('User.id')->from('User')->where("User.name ='foo.bar'"); $q->select('User.id')->from('User')->where("User.name ='foo.bar'");
......
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