I might not get this completely right, so anyone feel free to correct me.
It sounds like you need to have a belongsTo and hasMany relationship set up
between products and categories. If each product can only belong to one
category, and each category has many products, you would set it up like
this:

in product.php model file:
var belongsTo = 'Category';

and in category.php model file:
var hasMany = 'Product';

also, make sure that in the product table, there is a foreign key called
'category_id', that corresponds to the proper category id from the category
table.

Once this is set up like that, you should be able to perform a find() or
read() operation on your product controller, and it should fetch the related
category information as well. This is how I have my User and Updates tables
set up, and it's been working out for me.

In the name of Life, Liberty, and the pursuit of my sanity.
Siebren Bakker(Aevum Decessus)

On Wed, Jun 25, 2008 at 00:44, kaushik <[EMAIL PROTECTED]> wrote:

>
> I have a product table and a category table. primary key of category
> table i.e. category_id is foreign key. so in product module i want to
> show the category_name using this relation. how it is possible in
> cakephp? is there any tutorial? anyone can help me?
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to