Is there a way to select all fields from a specific table in CakePHP?
So something like:
$this->Model1->find('first',
array('fields' => 'Model2.*',
'conditions' => 'Model1.id = Model2.Model1_id'),
'contain' => array());
I’ve been looking all over the place and can’t find anything on this.
I’m kind of hoping that I don’t have to type out all of the fields for Model2 🙁
Forgive me for my nubishness, I just started learning Cake. Many thanks in advance!
You don’t. The syntax you have (meaning the
Model2.*part) will work, as will defining no fields at all. By default, they’re all returned.I don’t know, though, whether the
findcall as you have it will work. It seems awkward at best to be executing a find onModel1in order to get data fromModel2. As Henri mentioned in his comment, better to do the find onModel2.