Sunday, November 30, 2014

Cakephp 3, getting error referencing relation

Hello,

I took advice on these forums and decided to learn Cake 3.0 instead of 2.

In my controller I am getting product items and trying to reference child table brands.

$data = $this->Products->find('all')
->where(['Products.is_active' => 0])
->where(['Products.attributes LIKE' => $size.'%'])
->where(['Products.category_id =' => $catid])
   ->contain(['Brands']);

foreach($products as $row): 
$row->Brands->image_path; // this line is causing an error 

Trying to get property of non-object

--
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/d/optout.

No comments: