I am also facing a similar problem. I have created associations in
Past successfully. But sometimes even though everything looks correct
but we see no sign of association.

I want to ask Is there any way of checking where we are going wrong?

On Jan 30, 9:46 am, Mac65 <[EMAIL PROTECTED]> wrote:
> 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 cake-php@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to