Yet another "Call to a member function find on a non-object" error
I know this post gets written every couple of months, and I swear that I've read through all of the back posts, yet can't find a solution that works.
Whenever I try to call related data from one of my models, I get the above error. Below is the relationship code for each model.
class Slide extends AppModel {
public $name = 'Slide';
public $belongsTo = array(
'Module' => array(
'className' => 'Module',
'foreignKey' => 'module_id',
));
class Module extends AppModel {
public $name = 'Module';
public $hasMany = array(
'Slide' => array(
'className' => 'Slide',
'foreignKey' => 'module_id',
'order' => 'Slide.position ASC',
'dependent' => true
)
);
public $belongsTo = array(
'Creator' => array(
'className' => 'User'));
public $hasAndBelongsToMany = array(
'Learner' => array(
'className' => 'User',
'joinTable' => 'modules_users',
'foreignKey' => 'module_id',
'associationForeignKey' => 'users_id',
'unique' => 'keepExisting',
));
class User extends AppModel {
public $name = 'User';
public $uses = 'users';
public $hasMany = array(
'OModule' => array(
'className' => 'Module',
'foreignKey' => 'users_id',
'order' => 'Module.created DESC'
));
public $hasAndBelongsToMany = array(
'Module' => array( //We gotta remember this later...
'className' => 'Module',
'joinTable' => 'modules_users',
'foreignKey' => 'user_id',
'associationForeignKey' => 'module_id',
'unique' => 'keepExisting',
));
I've tried to adhere to all of the requirements outlined in the CookBook, but I know I must be doing something wrong. Any help is appreciated. Thanks in advance.
Andrew
-- Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
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+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home