Ok, I was able to get around the error messages with this:
// CategoryController
..
function view($id){
..
loadModel('Product');
$p = new Product();
$this->Product = $p->getProductsByCategory($id, $start, $limit,
$sort);
pr($this);
$this->set('category', $this->Category->read());
}
Would show that the Category['Product'] object was populated with an
array of products. For example
['Category']['Product'][0]['Product'][0]['product_name'] = 'Acme
XYZ123'
['Category']['Product'][1]['Product'][0]['product_name'] = 'Acme
MZ456'
However the view.thtml output did not show any recognition of a
Product object and I could not find a way to access it. Do I need to
do a Save() call or something?
I didn't even get into trying to build the ProductImage model which
brings up an important question...
With 1 query, can I build 2 or more Models??
For instance, if I call a function in the Product model that joins the
product_image table, can I use the output to build both the Product
and ProductImage models?
On May 9, 12:19 pm, "Jon Bennett" <[EMAIL PROTECTED]> wrote:
> > Hmm... ok, I understand setting up the function in the Product model
> > to run the query but I'm confused about the CategoryController.
> > If I try to run:
>
> $catProds = $this->Category->Product->getCategoryProducts($categoryId);
>
> you have to traverse the associations tree back. If you're working
> within CategoriesController, then Product is an associated table to
> Category.
>
> try pr($this->Category); // pr is cake shorthand for print_r
>
> hth
>
> jon
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---