not retrieving referenced class automatically if nested
The group you are posting to is a
Usenet group . Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
From:
wizhippo <wizhi... @gmail.com>
Date: Thu, 24 Apr 2008 06:52:51 -0700 (PDT)
Local: Thurs, Apr 24 2008 9:52 am
Subject: not retrieving referenced class automatically if nested
Example
class Agent extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('agents');
$this->hasColumns(array(
'agentid' => array(
'type' => 'integer',
'length' => null,
'primary' => true,
'sequence' => 'agents_agentid_seq',
'notnull' => true
),
'agentlink' => array(
'type' => 'integer',
'length' => null,
'notnull' => true
),
'commonname' => array(
'type' => 'string',
'length' => 255,
'notnull' => true
),
'firstname' => array(
'type' => 'string',
'length' => 255,
'notnull' => true
),
'lastname' => array(
'type' => 'string',
'length' => 255,
'notnull' => true
),
'middlename' => array(
'type' => 'string',
'length' => 255,
'notnull' => false
),
));
}
public function setUp()
{
$this->hasOne('Agent as Parent', array('local' => 'agentlink',
'foreign' => 'agentid'));
$this->hasMany('Agent as SubAgents', array('local' =>
'agentid', 'foreign' => 'agentlink'));
}
}
$agent = Doctrine::getTable('Agent')->find(14);
echo '<pre>';
print_r( $agent->Parent->toArray(true) );
print_r( $agent->SubAgents->toArray(true) );
results
Array
(
[agentid] =>
[agentlink] =>
[commonname] =>
[firstname] =>
[lastname] =>
[middlename] =>
)
Array
(
[0] => Array
(
[agentid] => 15
[agentlink] => 14
[commonname] => John Barton
[firstname] => John
[lastname] => Barton
[middlename] =>
)
)
Notice that the parent is emply. It does work if I use DQL and a join.
using 0.11
Any idea's as to why it automaticaly gets the SubAgents and not the
Parent?
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
wizhippo <wizhi... @gmail.com>
Date: Thu, 24 Apr 2008 07:10:14 -0700 (PDT)
Local: Thurs, Apr 24 2008 10:10 am
Subject: Re: not retrieving referenced class automatically if nested
I have done more digging and fount that the parent is not fetched
automatically if my agenlink = 0.
I do not believe this is the correct behavior.
On Apr 24, 9:52 am, wizhippo <wizhi... @gmail.com> wrote:
> Example
> class Agent extends Doctrine_Record
> {
> public function setTableDefinition()
> {
> $this->setTableName('agents');
> $this->hasColumns(array(
> 'agentid' => array(
> 'type' => 'integer',
> 'length' => null,
> 'primary' => true,
> 'sequence' => 'agents_agentid_seq',
> 'notnull' => true
> ),
> 'agentlink' => array(
> 'type' => 'integer',
> 'length' => null,
> 'notnull' => true
> ),
> 'commonname' => array(
> 'type' => 'string',
> 'length' => 255,
> 'notnull' => true
> ),
> 'firstname' => array(
> 'type' => 'string',
> 'length' => 255,
> 'notnull' => true
> ),
> 'lastname' => array(
> 'type' => 'string',
> 'length' => 255,
> 'notnull' => true
> ),
> 'middlename' => array(
> 'type' => 'string',
> 'length' => 255,
> 'notnull' => false
> ),
> ));
> }
> public function setUp()
> {
> $this->hasOne('Agent as Parent', array('local' => 'agentlink',
> 'foreign' => 'agentid'));
> $this->hasMany('Agent as SubAgents', array('local' =>
> 'agentid', 'foreign' => 'agentlink'));
> }
> }
> $agent = Doctrine::getTable('Agent')->find(14);
> echo '<pre>';
> print_r( $agent->Parent->toArray(true) );
> print_r( $agent->SubAgents->toArray(true) );
> results
> Array
> (
> [agentid] =>
> [agentlink] =>
> [commonname] =>
> [firstname] =>
> [lastname] =>
> [middlename] =>
> )
> Array
> (
> [0] => Array
> (
> [agentid] => 15
> [agentlink] => 14
> [commonname] => John Barton
> [firstname] => John
> [lastname] => Barton
> [middlename] =>
> )
> )
> Notice that the parent is emply. It does work if I use DQL and a join.
> using 0.11
> Any idea's as to why it automaticaly gets the SubAgents and not the
> Parent?
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
wizhippo <wizhi... @gmail.com>
Date: Thu, 24 Apr 2008 07:55:12 -0700 (PDT)
Local: Thurs, Apr 24 2008 10:55 am
Subject: Re: not retrieving referenced class automatically if nested
I have found the probel,
in LocalKey.php on line 49,
if (empty($id) || ! $this->definition['table']-
>getAttribute(Doctrine::ATTR_LOAD_REFERENCES)) {
if the id = 0 it is considered empty.
I don't believe this should be the case as 0 can be a id value.
On Apr 24, 10:10 am, wizhippo <wizhi... @gmail.com> wrote:
> I have done more digging and fount that the parent is not fetched
> automatically if my agenlink = 0.
> I do not believe this is the correct behavior.
> On Apr 24, 9:52 am, wizhippo <wizhi... @gmail.com> wrote:
> > Example
> > class Agent extends Doctrine_Record
> > {
> > public function setTableDefinition()
> > {
> > $this->setTableName('agents');
> > $this->hasColumns(array(
> > 'agentid' => array(
> > 'type' => 'integer',
> > 'length' => null,
> > 'primary' => true,
> > 'sequence' => 'agents_agentid_seq',
> > 'notnull' => true
> > ),
> > 'agentlink' => array(
> > 'type' => 'integer',
> > 'length' => null,
> > 'notnull' => true
> > ),
> > 'commonname' => array(
> > 'type' => 'string',
> > 'length' => 255,
> > 'notnull' => true
> > ),
> > 'firstname' => array(
> > 'type' => 'string',
> > 'length' => 255,
> > 'notnull' => true
> > ),
> > 'lastname' => array(
> > 'type' => 'string',
> > 'length' => 255,
> > 'notnull' => true
> > ),
> > 'middlename' => array(
> > 'type' => 'string',
> > 'length' => 255,
> > 'notnull' => false
> > ),
> > ));
> > }
> > public function setUp()
> > {
> > $this->hasOne('Agent as Parent', array('local' => 'agentlink',
> > 'foreign' => 'agentid'));
> > $this->hasMany('Agent as SubAgents', array('local' =>
> > 'agentid', 'foreign' => 'agentlink'));
> > }
> > }
> > $agent = Doctrine::getTable('Agent')->find(14);
> > echo '<pre>';
> > print_r( $agent->Parent->toArray(true) );
> > print_r( $agent->SubAgents->toArray(true) );
> > results
> > Array
> > (
> > [agentid] =>
> > [agentlink] =>
> > [commonname] =>
> > [firstname] =>
> > [lastname] =>
> > [middlename] =>
> > )
> > Array
> > (
> > [0] => Array
> > (
> > [agentid] => 15
> > [agentlink] => 14
> > [commonname] => John Barton
> > [firstname] => John
> > [lastname] => Barton
> > [middlename] =>
> > )
> > )
> > Notice that the parent is emply. It does work if I use DQL and a join.
> > using 0.11
> > Any idea's as to why it automaticaly gets the SubAgents and not the
> > Parent?
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
"Jonathan Wage" <jonw... @gmail.com>
Date: Mon, 28 Apr 2008 15:30:49 -0500
Local: Mon, Apr 28 2008 4:30 pm
Subject: Re: [doctrine-user] Re: not retrieving referenced class automatically if nested
This is fixed now. I am pretty sure you are the one who created the ticket. Thanks for uncovering this and reporting it. - Jon
On Thu, Apr 24, 2008 at 9:55 AM, wizhippo <wizhi
... @gmail.com> wrote:
> I have found the probel,
> in LocalKey.php on line 49,
> if (empty($id) || ! $this->definition['table']- > >getAttribute(Doctrine::ATTR_LOAD_REFERENCES)) {
> if the id = 0 it is considered empty.
> I don't believe this should be the case as 0 can be a id value.
> On Apr 24, 10:10 am, wizhippo <wizhi... @gmail.com> wrote: > > I have done more digging and fount that the parent is not fetched > > automatically if my agenlink = 0.
> > I do not believe this is the correct behavior.
> > On Apr 24, 9:52 am, wizhippo <wizhi... @gmail.com> wrote:
> > > Example
> > > class Agent extends Doctrine_Record > > > { > > > public function setTableDefinition() > > > { > > > $this->setTableName('agents'); > > > $this->hasColumns(array( > > > 'agentid' => > array( > > > 'type' => 'integer',
> 'length' => null, > > > 'primary' => true, > > > 'sequence' => 'agents_agentid_seq',
> 'notnull' => true > > > ), > > > 'agentlink' => > array( > > > 'type' => 'integer',
> 'length' => null,
> 'notnull' => true > > > ), > > > 'commonname' => array( > > > 'type' => 'string', > > > 'length' => 255, > > > 'notnull' => true > > > ), > > > 'firstname' => array( > > > 'type' => 'string', > > > 'length' => 255, > > > 'notnull' => true > > > ), > > > 'lastname' => array( > > > 'type' => 'string', > > > 'length' => 255, > > > 'notnull' => true > > > ), > > > 'middlename' => array( > > > 'type' => 'string', > > > 'length' => 255, > > > 'notnull' => false > > > ), > > > )); > > > }
> > > public function setUp() > > > { > > > $this->hasOne('Agent as Parent', array('local' => 'agentlink', > > > 'foreign' => 'agentid')); > > > $this->hasMany('Agent as SubAgents', array('local' => > > > 'agentid', 'foreign' => 'agentlink')); > > > }
> > > }
> > > $agent = Doctrine::getTable('Agent')->find(14);
> > > echo '<pre>'; > > > print_r( $agent->Parent->toArray(true) ); > > > print_r( $agent->SubAgents->toArray(true) );
> > > results
> > > Array > > > ( > > > [agentid] => > > > [agentlink] => > > > [commonname] => > > > [firstname] => > > > [lastname] => > > > [middlename] => > > > ) > > > Array > > > ( > > > [0] => Array > > > ( > > > [agentid] => 15 > > > [agentlink] => 14 > > > [commonname] => John Barton > > > [firstname] => John > > > [lastname] => Barton > > > [middlename] => > > > )
> > > )
> > > Notice that the parent is emply. It does work if I use DQL and a join. > > > using 0.11
> > > Any idea's as to why it automaticaly gets the SubAgents and not the > > > Parent?
-- Jonathan Wage http://www.jwage.com http://www.centresource.com
You must
Sign in before you can post messages.
You do not have the permission required to post.