#1508: Problem placing the from() later in Doctrine_Query
-----------------------------------+----------------------------------------
Reporter: colnector | Owner: romanb
Type: defect | Status: new
Priority: minor | Milestone:
Component: Query/Hydration | Version: 1.0.2
Keywords: | Has_test: 0
Mystatus: Pending Core Response | Has_patch: 0
-----------------------------------+----------------------------------------
This works:
{{{
$q = Doctrine_Query::create()
->select('i.list_type')
->from('Inventory i')
->where('i.item_id =?', array($item_id))
->innerJoin('i.sfGuardUser gu WITH gu.is_active =
true')
->orderBy('i.list_type, gu.username')
;
$res = $q->execute(array(), Doctrine::HYDRATE_ARRAY);
}}}
This raises an exception:
{{{
$q = Doctrine_Query::create()
->select('i.list_type')
->where('i.item_id =?', array($item_id))
->innerJoin('i.sfGuardUser gu WITH gu.is_active =
true')
->orderBy('i.list_type, gu.username')
;
$q = $q->from('Inventory i');
$res = $q->execute(array(), Doctrine::HYDRATE_ARRAY);
}}}
Some stack trace:
{{{
[Doctrine_Exception]
Couldn't find class gu
stack trace
* at ()
in
SF_ROOT_DIR\plugins\sfDoctrinePlugin\lib\doctrine\Doctrine\Table.php line
268 ...
265. {
266. $name = $this->_options['name'];
267. if ( ! class_exists($name) || empty($name)) {
268. throw new Doctrine_Exception("Couldn't find
class " . $name);
269. }
270. $record = new $name($this);
271.
* at Doctrine_Table->initDefinition()
in
SF_ROOT_DIR\plugins\sfDoctrinePlugin\lib\doctrine\Doctrine\Table.php line
228 ...
225. $this->_parser = new
Doctrine_Relation_Parser($this);
226.
227. if ($initDefinition) {
228. $this->record = $this->initDefinition();
229.
230. $this->initIdentifier();
231.
* at Doctrine_Table->__construct('gu',
object('Doctrine_Connection_Mysql'), '1')
in
SF_ROOT_DIR\plugins\sfDoctrinePlugin\lib\doctrine\Doctrine\Connection.php
line 1116 ...
1113. in_array('Doctrine_Table',
class_parents($class))) {
1114. $table = new $class($name, $this, true);
1115. } else {
1116. $table = new Doctrine_Table($name, $this,
true);
1117. }
1118.
1119. $this->tables[$name] = $table;
* at Doctrine_Connection->getTable('gu')
in
SF_ROOT_DIR\plugins\sfDoctrinePlugin\lib\doctrine\Doctrine\Query.php line
1712 ...
1709. $this->_conn =
$manager->getConnectionForComponent($name);
1710. }
1711.
1712. $table = $this->_conn->getTable($name);
1713. $tableName = $table->getTableName();
1714.
1715. // get the short alias for this table
* at Doctrine_Query->loadRoot('gu', 'gu')
in
SF_ROOT_DIR\plugins\sfDoctrinePlugin\lib\doctrine\Doctrine\Query.php line
1522 ...
1519. if ( ! isset($table)) {
1520. // process the root of the path
1521.
1522. $table = $this->loadRoot($name,
$componentAlias);
1523. } else {
1524. $join = ($delimeter == ':') ? 'INNER
JOIN ' : 'LEFT JOIN ';
1525.
* at Doctrine_Query->load('gu')
in
SF_ROOT_DIR\plugins\sfDoctrinePlugin\lib\doctrine\Doctrine\Query.php line
687 ...
684. $componentAlias =
$this->getRootAlias();
685. }
686.
687.
$this->load($componentAlias);
688.
689. // check the existence
of the component alias
690. if ( !
isset($this->_queryComponents[$componentAlias])) {
* at Doctrine_Query->parseClause(' gu.username')
in
SF_ROOT_DIR\plugins\sfDoctrinePlugin\lib\doctrine\Doctrine\Query\Orderby.php
line 47 ...
44. $ret = array();
45.
46. foreach (explode(',', trim($str)) as $r) {
47. $r = $this->query->parseClause($r);
48.
49. $ret[] = $r;
50. }
* at Doctrine_Query_Orderby->parse('i.list_type, gu.username')
in
SF_ROOT_DIR\plugins\sfDoctrinePlugin\lib\doctrine\Doctrine\Query\Abstract.php
line 2000 ...
}}}
--
Ticket URL: <http://trac.doctrine-project.org/ticket/1508>
Doctrine <http://www.phpdoctrine.org>
PHP Doctrine Object Relational Mapper
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"doctrine-svn" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.co.uk/group/doctrine-svn?hl=en-GB
-~----------~----~----~----~------~----~------~--~---