tags:

views:

31

answers:

1

I have the following model

class Comment extends AppModel {
    var $useTable = "comments";
    var $recursive = 1;

    var $belongsTo = array(
                    'User' => array(
                        'className' => 'User',
                        'foreignKey'    => 'userID'

                    )
                );

    function bindCommentsToUser() {

        $this->bindModel(
            array('belongsTo' => array(
                    'User' => array(
                        'className' => 'User',
                        'foreignKey'    => 'userID'

                    )
                )
            )
        ); 
    }

The belongsTo variable at the top does absolutely nothing, I just cannot get it to work. To confirm that the binding exists, I created the lower function to do dynamic binding which works perfectly. There appears to be no difference between the two. Is there some mistake that I am making or is there some setting somewhere else that has to be set?

+1  A: 

There should be the same in both cases. You may want to create a ticket at http://cakephp.lighthouseapp.com. If possible change 'userID' to 'user_id' as recommended Travis Lleu. That will work for sure.

bancer
chaning the database columns to _id worked. Will open a ticket when I get a chance
paullb