I'm completely baffled by an association that's not working... I'm sure I've done this hundreds of times with no problems, but I just cannot see what's going on here! I think I must be missing something really obvious.
So, I have 2 tables. One is called "Retailers" and all records in there have a unique id. The second is called "Retailerfollows" and it has the field "retailer_id"
What I want is to be able to retrieve a Retailerfollows record, and to get the corresponding Retailer along with it.
I have defined the following association in Retailerfollow.php:
In my controller, I have:
I don't think I should even need Recursive set to 2, but I'm trying anything I can think of!
When I debug this, I get:
It's not retrieving the corresponding Retailer records. I've tried various things, including Containable behaviour, but with no success. I've checked spellings everywhere, but found nothing wrong. I've deleted the cache files, and that didn't help.
I know it's probably something really simple, but I just can't spot it! Can anyone help, or suggest what I should try next to debug?
Thanks!
-- So, I have 2 tables. One is called "Retailers" and all records in there have a unique id. The second is called "Retailerfollows" and it has the field "retailer_id"
What I want is to be able to retrieve a Retailerfollows record, and to get the corresponding Retailer along with it.
I have defined the following association in Retailerfollow.php:
public $belongsTo = array(
'Retailer' => array(
'className' => 'Retailer',
'foreignKey' => 'retailer_id'
)
);
In my controller, I have:
$this->Retailerfollow->recursive = 2;
debug($this->Retailerfollow->find('all'));
I don't think I should even need Recursive set to 2, but I'm trying anything I can think of!
When I debug this, I get:
array( (int) 0 => array( 'Retailerfollow' => array( 'id' => '1', 'retailer_id' => '3' ) ), (int) 1 => array( 'Retailerfollow' => array( 'id' => '3', 'retailer_id' => '3' ) ) )
It's not retrieving the corresponding Retailer records. I've tried various things, including Containable behaviour, but with no success. I've checked spellings everywhere, but found nothing wrong. I've deleted the cache files, and that didn't help.
I know it's probably something really simple, but I just can't spot it! Can anyone help, or suggest what I should try next to debug?
Thanks!
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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment