Re: Return field from second joined table

2006-08-21 Thread ShepherdWeb

Here's my solution.  It's not the most elegant in the world, but it
gets the job done.  If anyone has a suggestion for a better way, please
chime in.

$categoryData = $this->requestAction('/categories/select/');

$this->Product->Color->id = $color_id;
$data = $this->Product->Color->read();
for ($i=0; $iset('products', $data['Product']);

basically, I'm getting the category data, then getting the product data
related to the selected color...and finally looping through the
products and adding the category title.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Return field from second joined table

2006-08-21 Thread ShepherdWeb

I found that I can use find() instead of read(), and set recursive = 2
to return category.title, however, this returns way more data than I
need and drastically affects performance.  Not a usable solution.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Return field from second joined table

2006-08-21 Thread ShepherdWeb

What am I doing wrong?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Return field from second joined table

2006-08-21 Thread ShepherdWeb

Nope.  It's not there.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: Return field from second joined table

2006-08-21 Thread Chris Hartjes

Isn't that info available in $data['Category']?  Given the
relationships you've established I think it would be there.

On 8/21/06, ShepherdWeb <[EMAIL PROTECTED]> wrote:
>
> Color and Product are hasAndBelongsToMany to each other
>
> Product belongsTo Category
>
> Category hasMany Product
>
> I'm using this code to show products by color:
>
>
> $this->Product->Color->id = $color_id;
> $data = $this->Product->Color->read();
> $this->set('products', $data['Product']);
>
> this returns this array:
>
> Array
> (
> [0] => Array
> (
> [id] => 51
> [title] =>  Pink Polka dot Headband
> [description] => This is our best selling headband!  We
> start with a stretch cotton headband that is oh so comfy, then top it
> off with an adorable light pink and white polka dot grosgrain bow. This
> bow has a pink and white knotted center.  This headband is a classic
> and one your little girl will wear for years! Fits ages 4 months - 4
> years.
> [inventory] => 2
> [price] => 4.99
> [category_id] => 1
> [sale_date] => -00-00
> [sale_price] => 0
> )
>
> [1] => Array
> (
> [id] => 52
> [title] => Double Ruffle Satin Bow
> [description] => How could you live without this one?
> Bowhead Babies favorite bow of all, the double ruffle satin bow.  This
> bow is perfect for dresses and casual play clothes.  It has a matching
> satin knotted center and covered scissor clip back.  This bow measures
> 3" and is great for newborn to toddler girls.  It looks great in a lace
> headband or in pigtails! Look at our 5 piece set deal!
> [inventory] => 5
> [price] => 3.99
> [category_id] => 1
> [sale_date] => -00-00
> [sale_price] => 0
> )
>
> )
>
> I would like to be able to return category.title to the view also.  How
> do I do this?
>
>
> >
>


-- 
Chris Hartjes

"The greatest inefficiencies come from solving problems you will never have."
-- Rasmus Lerdorf

@TheBallpark - http://www.littlehart.net/attheballpark
@TheKeyboard - http://www.littlehart.net/atthekeyboard

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Return field from second joined table

2006-08-20 Thread ShepherdWeb

Color and Product are hasAndBelongsToMany to each other

Product belongsTo Category

Category hasMany Product

I'm using this code to show products by color:


$this->Product->Color->id = $color_id;
$data = $this->Product->Color->read();
$this->set('products', $data['Product']);

this returns this array:

Array
(
[0] => Array
(
[id] => 51
[title] =>  Pink Polka dot Headband
[description] => This is our best selling headband!  We
start with a stretch cotton headband that is oh so comfy, then top it
off with an adorable light pink and white polka dot grosgrain bow. This
bow has a pink and white knotted center.  This headband is a classic
and one your little girl will wear for years! Fits ages 4 months - 4
years.
[inventory] => 2
[price] => 4.99
[category_id] => 1
[sale_date] => -00-00
[sale_price] => 0
)

[1] => Array
(
[id] => 52
[title] => Double Ruffle Satin Bow
[description] => How could you live without this one?
Bowhead Babies favorite bow of all, the double ruffle satin bow.  This
bow is perfect for dresses and casual play clothes.  It has a matching
satin knotted center and covered scissor clip back.  This bow measures
3" and is great for newborn to toddler girls.  It looks great in a lace
headband or in pigtails! Look at our 5 piece set deal!
[inventory] => 5
[price] => 3.99
[category_id] => 1
[sale_date] => -00-00
[sale_price] => 0
)

)

I would like to be able to return category.title to the view also.  How
do I do this?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---