This is using 1.2.0.6311 beta
I may be mistaken about how this should work, but I thought setting
the belongsTo variable in a model would cause it to join automatically
when using the find ('all') method on that model.
I have two models:
class Collector extends AppModel
{
var $name = 'Collector';
var $belongsTo = array('User' =>
array('className' => 'User',
'fieldName' => 'User.first_name')
);
}
class User extends AppModel
{
var $name = 'User';
var $hasMany = array('Collector' =>
array('className' => 'Collector')
);
}
I'm trying to access the Collector model from my AppController class.
It looks something like this:
class AppController extends Controller {
var $uses = array('Users', 'Collectors');
function beforeFilter()
{
$collectors = $this->Collectors->find ('all', array (
'fields' => array ('id',
'name', 'User.first_name', 'User.last_name'),
'recursive' => 0)
);
}
}
The find does not join the records and I get a SQL error about unknown
table 'User'.
If I use bindModel and manually set the belongsTo information right
before calling the find, then it works fine.
It looks like my 'var $belongsTo' is not getting set in the collector
model for some reason, but I can't figure out why.
Thanks for any help.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" 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.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---