This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » support » General discussion » Doctrine where vs addWhere vs andWhere
Doctrine where vs addWhere vs andWhere [message #97037] Fri, 09 April 2010 17:00 Go to next message
chrisyue  is currently offline chrisyue
Messages: 75
Registered: May 2009
Member
Can some one tell the difference among the 3 methods?
Re: Doctrine where vs addWhere vs andWhere [message #97055 is a reply to message #97037 ] Sat, 10 April 2010 03:52 Go to previous messageGo to next message
hopscotch1978  is currently offline hopscotch1978
Messages: 258
Registered: January 2010
Location: Spain
Faithful Member

Not really sure, probably just a proxy method.

I use "andWhere" lots. Works fine, comes out as expected ("AND").
Re: Doctrine where vs addWhere vs andWhere [message #97067 is a reply to message #97037 ] Sat, 10 April 2010 05:03 Go to previous message
hopscotch1978  is currently offline hopscotch1978
Messages: 258
Registered: January 2010
Location: Spain
Faithful Member
(strange, I added an earlier reply to this but it seems to have disappeared?)

See here: http://www.symfony-project.org/doctrine/1_2/en/06-Working-Wi th-Data

For simplicity's sake, the "where" is a WHERE and the "andWhere" is an AND. I think the "addWhere" is a proxy method for "andWhere".

So in Doctrine 1.2 for example:

$q = Doctrine_Query::create()
 ->where('id = 1')
 ->andWhere('type = 1')
$result = $q->execute();


... is the same as:

$q = Doctrine_Query::create()
 ->where('id = 1 AND type = 1')
$result = $q->execute();


The "andWhere" is useful when you need to play with query object in separate steps, for example:

$q = Doctrine_Query::create()
 ->where('id = 1');

if($var = 'blue') $q->andWhere('type = 1');
if($var = 'red') $q->andWhere('type = 2');

$result = $q->execute();



[Updated on: Sat, 10 April 2010 05:03]

Previous Topic:Is symfony a good solution for creating complex forms?
Next Topic:Sporadic ERROR: Unable to read cache file
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software