Hi! I'm a beginner in Cake and can't understand one thing, maybe you
more experienced people will know the solution:-)
So, I have two tables in db: products (id,name) and productsizes
(id,product_id,size);
Two models: Product, Productsize;

product.php:
class Product extends AppModel
{
        var $name = 'Product';
        var $hasMany = array('Productsize' => array(
                'className'=>'Productsize',
                'foreignKey'=>'product_id')
        );
}

productsize.php:
class Productsize extends AppModel
{
        var $name = 'Productsize';
        var $belongsTo = 'Product';
}

And products_controller looks like:
class ProductsController extends AppController
{
        var $name = 'Products';
        var $uses = array('Product','Category','Productsize');
        var $layout = 'default';

        function display($c_name) {
                $this->set('category_name',$c_name);                        
//this
is just
                $c_id=$this->Category->find('name=\''.$c_name.'\'','id');  //for
retrivieng category
                $this->set('products',$this->Product-
>findAllByCategoryId($c_id['Category']['id']));   //here i get all
data about products
                $this->pageTitle = $c_name;
        }
}

And my question is: how do I retrieve data from productsizes? In
action "display" I want to show all products from one category and I
need to display the possible sizes for each one. How to do that in one
action?



Controller: products_controller


--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to