On Tue, Aug 24, 2010 at 2:31 PM, Philip Thompson <[email protected]> wrote:
> Hi all.
>
> Sorry for all these newb questions... trying to learn this stuff. Here's the 
> relationships and tables I have:
>
> Relationships:
> Hardware HABTM Configuration
> Configuration belongsTo ConfigurationType
>
> Tables:
> configurations
>    - configuration_type_id
> configurations_hardwares
>    - configuration_id
>    - hardware_id
> configuration_types
> hardwares
>
> When pulling the information for a specific Hardware record, I'm successfully 
> getting the Configurations associated with it, but I'm not getting the 
> information from the configuration_types table. How do I get info from this 
> other table?
>
> <?php
> $options['conditions'] = array('Hardware.id'=>$id);
> $this->Hardware->find('first', $options);
> ?>
>
> produces...
>
> Array
> (
>    [Hardware] => Array
>        (
>            [id] => 3
>            [hardware_type_id] => 2
>            [name] => w-irv-win7dev
>            [description] => Philip Thompson's Windows 7 machine
>            [location_id] => 1
>        )
>
>    [Configuration] => Array
>        (
>            [0] => Array
>                (
>                    [id] => 1
>                    [configuration_type_id] => 1
>                    [configuration] => Windows 7 Professional
>                    [description] =>
>                    [ConfigurationsHardware] => Array
>                        (
>                            [id] => 1
>                            [configuration_id] => 1
>                            [hardware_id] => 3
>                        )
>                )
>
>            [1] => Array
>                (
>                    [id] => 3
>                    [configuration_type_id] => 5
>                    [configuration] => Yes
>                    [description] =>
>                    [ConfigurationsHardware] => Array
>                        (
>                            [id] => 2
>                            [configuration_id] => 3
>                            [hardware_id] => 3
>                        )
>                )
>        )
> )
>
> I get the configuration_type_id result, but I want other fields from 
> configuration_type. Any help would be greatly appreciated on how to 
> accomplish this!
>

You need to increase the "recursive" value:

$options['recursive'] = 2;

I recommend you take a look at ContainableBehavior, though. It gives
one much more control (recursive == 2 can fetch too much data).

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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