Sorry, I tried to use the search, but I don't even know what keyword to
look for: Here is my database structure
CREATE TABLE `customers` (
`id` int(10) unsigned NOT NULL,
`name` varchar(64) NOT NULL,
PRIMARY KEY (`id`)
)
CREATE TABLE `products` (
`id` int(10) unsigned NOT NULL,
`name` varchar(64) NOT NULL,
PRIMARY KEY (`id`)
)
CREATE TABLE `orders` (
`id` int(10) unsigned NOT NULL,
`product_id` int(10) unsigned NOT NULL,
`customer_id` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`)
)
I want to list all the rows in table 'orders', with each product_id and
customer_id associated with their names. I assume using hasMany is the
key here.
var $hasMany = array('Product' =>
array('className' => 'Product',
'foreignKey' =>
'product_id',
'dependent' => true,
'exclusive' => false,
'finderSql' => ''
),
'Customer' =>
array('className' =>
'Customer',
'foreignKey' =>
'customer_id',
'dependent' => true,
'exclusive' => false,
'finderSql' => ''
)
);
The above doesn't seem to work, when I call Order->findAll(), I don't
see each customer_id and product_id being associated with their
respective names. Basically, I am trying to do this: SELECT
orders.id,customers.name,products.name FROM orders,customers,products
WHERE orders.product_id = products.id AND orders.customer_id =
customers.id; What did I miss here? Thanks.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" 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
-~----------~----~----~----~------~----~------~--~---