Hey guys, I am extremely new to cake and i've been struggling trying to
create a single find query. My database has 4 tables, customers, phones,
customers_phones, and phonetypes. The customers table HABTM phones via
customers_phones, and the phones table has a foreign key from phonetypes,
indicating the type of phone number. some sample data might look like this:
customers(id, name) = (1, 'bob')
customers_phones(id, customer_id, phone_id) = (1, 1, 4)
phones(id, number, phonetype_id) = (4,5555555,3)
phonetypes(id, typename) = (3, 'work')
I made models for phone, customer and phonetype, and in my
customers_controller i was able to find phone numbers related to a specific
customer by using:
var $uses = array('Customer', 'Phone');
$condt = array('conditions'=>array('customer.id'=>$id));
$phones = $this->Phone->Customer->find('all', $condt);
this works fine, except it returns the phonetype_id, and i need to see
phonetypes.typename. Been trying to work but so far i've been unsuccessful.
I can get the data i need using query, but the documentation claims there
are 'very few circumstances' where that is true, so i want to be a good
coder and avoid it.
Any help at all will be greatly appreciated! thanks in advance!
also, sorry if i posted a repeat question, i'm not too sure how to define
the problem to begin with, so searching has also been rather unsuccessful,
lol.
--
View this message in context:
http://old.nabble.com/single-find-query-involving-HABTM-and-hasOne-tp28940627p28940627.html
Sent from the CakePHP mailing list archive at Nabble.com.
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en