Asim Zaidi
Asim Zaidi

Reputation: 28344

model get join tables

I am new to cakephp. I have table customers with this

 id, product_id, created, modified

and my product table has this

id, label, cost

I want to select all the records from customer table which has the product_id in product table (join on id may be)?

How can I do that

Upvotes: 0

Views: 63

Answers (1)

Corey
Corey

Reputation:

You should write a hasMany association in your model for the table you would like to query, then do your $this->Model->find('all'...) query and make sure in your options you specify recursive=>1 so that it will get your associated data. http://book.cakephp.org/view/1043/hasMany

Upvotes: 2

Related Questions