I built DB with tables:
restaurants - main table
kitchens - second table
kitchen_restaurants - join table with fields: id, kitchen_id, restaurant_id
kitchens - second table
kitchen_restaurants - join table with fields: id, kitchen_id, restaurant_id
Model/Restaurant.php:
public $hasMany = array(
'KitchenRestaurant'
);
Model/Kitchen.php:
public $hasMany = array(
'KitchenRestaurant'
);
Model/KitchenRestaurant.php:
public $belongsTo = array(
'Restaurant', 'Kitchen'
);
I added
public $uses = array('Restaurant');
to my main page controller and here comes the part where I need your advices.
I need to select only those restaurants where kitchen = $id. I've tried to add
to my main page controller and here comes the part where I need your advices.
I need to select only those restaurants where kitchen = $id. I've tried to add
public function index() {
$this->set('rests', $this->Restaurant->find('all', array( 'conditions' => array('Restaurant.active' => "1", 'KitchenRestaurant.id' => "1") ))); }
$this->set('rests', $this->Restaurant->find('all', array( 'conditions' => array('Restaurant.active' => "1", 'KitchenRestaurant.id' => "1") ))); }
but I get Column not found error. How to properly retrieve data in hasMany through or HABTM?
Thanks!
-- Like Us on FacekBook 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.
No comments:
Post a Comment