Re: Problem calling ModelA-find('list') with a belongTo ModelB with a specific conditions

2010-08-19 Thread someguy
Hi

What your seeing is correct.

find('list') sets the recursive value to -1 (meaning no joins).
find('list') is commonly used to build up a list of key, value pairs
for a select box so doesn't normally need to join any models. If you
do want it to use the joins call

ModelA-find('list', array('recursive'=1))

Hope that helps


On Aug 17, 4:58 pm, Mariano mcerde...@gmail.com wrote:
 Hello,

 I have a ModelA with a belongTo with a condition, like:

 class ModelA extends AppModel {
  var $name = 'ModelA';
  var $belongsTo = array( 'ModelB' = array ('type' = 'inner',
 'conditions' = array ( 'ModelB.id' = '1' ) ) );

 }

 calling

 ModelA-find('all) the query is executed as follow:

 SELECT ... AS ... FROM `model_a` AS `ModelA` inner JOIN `model_b` AS
 `ModelB` ON (`ModelA`.`model_b_id` = `ModelB`.`id` AND `ModelB`.`id` =
 1) WHERE 1 = 1

 but calling:

 ModelA-find('list') the query is executed in an other  way (which I
 think is wrong):

 SELECT ... AS ... FROM `model_a` AS `ModelA` WHERE 1 = 1

 without the JOIN and the ON condition.

 Is this a bug? Is something wrong in my code?

 Thanks and Regards,
 Mariano.-

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Problem calling ModelA-find('list') with a belongTo ModelB with a specific conditions

2010-08-17 Thread Mariano
Hello,

I have a ModelA with a belongTo with a condition, like:

class ModelA extends AppModel {
 var $name = 'ModelA';
 var $belongsTo = array( 'ModelB' = array ('type' = 'inner',
'conditions' = array ( 'ModelB.id' = '1' ) ) );
}

calling

ModelA-find('all) the query is executed as follow:

SELECT ... AS ... FROM `model_a` AS `ModelA` inner JOIN `model_b` AS
`ModelB` ON (`ModelA`.`model_b_id` = `ModelB`.`id` AND `ModelB`.`id` =
1) WHERE 1 = 1

but calling:

ModelA-find('list') the query is executed in an other  way (which I
think is wrong):

SELECT ... AS ... FROM `model_a` AS `ModelA` WHERE 1 = 1

without the JOIN and the ON condition.

Is this a bug? Is something wrong in my code?

Thanks and Regards,
Mariano.-

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en