Re: hasMany through - how to retrieve my data?
Maybe linkable will help you. https://github.com/Terr/linkable Robert -- 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+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en.
Re: hasMany through - how to retrieve my data?
I also tried HABTM with the same result, I can't retrieve the data that I need. But as fas as I know there is no big difference between hasMany through (Join Model) and HABTM. I'll be glad if you help me correctly retrieve my data with conditions I posted in the first message, no matter if you choose HABTM or Join Model (I know how to setup both of them). On Monday, September 17, 2012 6:35:18 AM UTC+4, jsundquist wrote: Why are you using a hasMany instead of a hasAndBelongsToMany? You wouldn't need the id column as you two ideas together would be your index. - The cold winds are rising On Sep 16, 2012 5:17 PM, Nvp leh...@gmail.com javascript: wrote: Hi! I built DB with tables: *restaurants* - main table *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' ); The problem is that I have separate controller for my main page in which I need to retrieve data from this models with complex conditions. 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 public function index() { $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...@googlegroups.comjavascript: . To unsubscribe from this group, send email to cake-php+u...@googlegroups.com javascript:. Visit this group at http://groups.google.com/group/cake-php?hl=en. -- 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+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en.
hasMany through - how to retrieve my data?
Hi! I built DB with tables: *restaurants* - main table *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' ); The problem is that I have separate controller for my main page in which I need to retrieve data from this models with complex conditions. 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 public function index() { $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+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en.
Re: hasMany through - how to retrieve my data?
Why are you using a hasMany instead of a hasAndBelongsToMany? You wouldn't need the id column as you two ideas together would be your index. - The cold winds are rising On Sep 16, 2012 5:17 PM, Nvp leh...@gmail.com wrote: Hi! I built DB with tables: *restaurants* - main table *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' ); The problem is that I have separate controller for my main page in which I need to retrieve data from this models with complex conditions. 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 public function index() { $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+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en. -- 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+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en.