Hi Alan,

Thanks for the idea.  I tried using 'contain' just now and I still am
just seeing ATable and BTable results in the returned array.  I'll
keep playing around with containable anyhow...

Andy


On Apr 15, 7:16 pm, "Alan Asher" <a...@asteriskpound.com> wrote:
> I think you need a contain to include the third table.
>
> $this->ATable->find('all',
> array('contain'=>array('BTable','BTable.CTable')));
>
> That's just off the hip
>
> Alan
>
>
>
> -----Original Message-----
> From: cake-php@googlegroups.com [mailto:cake-...@googlegroups.com] On Behalf
>
> Of andy
> Sent: Thursday, April 15, 2010 6:25 PM
> To: CakePHP
> Subject: Re: Multi-level Models in CakePHP
>
> Or maybe I'm trying to go for returned data in this type of format...
> though I don't know if it's possible:
>
>  Array
>  (
>      [0] => Array
>          (
>              [ATable] => Array
>                  (
>                      [id] => 1
>                      [name] => A
>                      [weight] => 1
>                  )
>
>              [BTable] => Array
>                  (
>                      [id] => 1
>                      [name] => B
>                      [a_table_id] => 1
>                      [weight] => 1
>
>                      Array
>                      (
>                               [0] => Array
>                                        (
>                                                  [CTable] => Array
>
> (
>
> [id] => 1
>
> [name] => C
>
> [b_table_id] => 1
>
> [weight] => 1
>                                                                        )
>                                         )
>                      )
>                )
>
>          )
>
>  )
>
> On Apr 15, 5:38 pm, andy <sum...@gmail.com> wrote:
> > Has anyone successfully been able to do something like this?  (I'm
> > using CakePHP 1.3 RC4)
>
> > I have three models:
>
> > class ATable extends AppModel {
>
> >     var $name = 'ATable';
> >     var $hasOne = array('BTable' => array( 'foreignKey' => false,
> >                                             'type' => 'INNER',
> >                                             'conditions' => array(
> >                                                 'BTable.a_table_id =
> > ATable.id') )
> >                         );
>
> > }
>
> > class BTable extends AppModel {
>
> >     var $name = 'BTable';
> >     var $hasOne = array('CTable' => array( 'foreignKey' => false,
> >                                             'type' => 'INNER',
> >                                             'conditions' => array(
> >                                                 'CTable.b_table_id =
> > BTable.id') )
> >                         );
>
> > }
>
> > class CTable extends AppModel {
>
> >     var $name = 'CTable';
>
> > }
>
> > And I have the following MySQL tables:
>
> > CREATE TABLE a_tables (
> >     id INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
> >     name VARCHAR(255),
> >     schedule_template_id INT(11),
> >     weight INT(11)
> > );
>
> > INSERT INTO a_tables (name, weight)
> >     VALUES ('A', 1);
>
> > CREATE TABLE b_tables (
> >     id INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
> >     name VARCHAR(255),
> >     a_table_id INT(11),
> >     weight INT(11)
> > );
>
> > INSERT INTO b_tables (name, a_table_id, weight)
> >     VALUES ('B', 1, 1);
>
> > CREATE TABLE c_tables (
> >     id INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
> >     name VARCHAR(255),
> >     b_table_id INT(11),
> >     weight INT(11)
> > );
>
> > INSERT INTO c_tables (name, b_table_id, weight)
> >     VALUES ('C', 1, 1);
>
> > In my a_tables_controller.php file it looks like the following:
>
> > class ATablesController extends AppController {
>
> >     var $name = 'ATables';
>
> >     function index() {
> >         $this->set('a_var', $this->ATable->find('all'));
> >     }
>
> > }
>
> > And I am expecting CakePHP to set a variable that looks like the
> > following:
>
> > Array
> > (
> >     [0] => Array
> >         (
> >             [ATable] => Array
> >                 (
> >                     [id] => 1
> >                     [name] => A
> >                     [schedule_template_id] =>
> >                     [weight] => 1
> >                 )
>
> >             [BTable] => Array
> >                 (
> >                     [id] => 1
> >                     [name] => B
> >                     [a_table_id] => 1
> >                     [weight] => 1
> >                 )
>
> >             [CTable] => Array
> >                 (
> >                     [id] => 1
> >                     [name] => C
> >                     [b_table_id] => 1
> >                     [weight] => 1
> >                 )
>
> >         )
>
> > )
>
> > But in reality... this is all I am getting back (just the first two
> > models):
>
> > Array
> > (
> >     [0] => Array
> >         (
> >             [ATable] => Array
> >                 (
> >                     [id] => 1
> >                     [name] => A
> >                     [schedule_template_id] =>
> >                     [weight] => 1
> >                 )
>
> >             [BTable] => Array
> >                 (
> >                     [id] => 1
> >                     [name] => B
> >                     [a_table_id] => 1
> >                     [weight] => 1
> >                 )
>
> >         )
>
> > )
>
> > Any idea why CakePHP isn't giving me a complete "tree" of results?  I
> > read about something similar happening for someone else at this
> link:http://groups.google.com/group/cake-php/browse_thread/thread/24444f19..
> .
>
> > And it sounds like something that was addressed with CakePHP 1.3.  So
> > I'm using 1.3 (RC4)... yet it doesn't seem to allow me to use multi-
> > level models.
>
> > Thanks for any help,
> > Andy
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp 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 cake-php@googlegroups.com
> > To unsubscribe from this group, send email to
> > cake-php+unsubscr...@googlegroups.com For more options, visit this group
> athttp://groups.google.com/group/cake-php?hl=en
>
> Check out the new CakePHP Questions sitehttp://cakeqs.organd 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 cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group 
> athttp://groups.google.com/group/cake-php?hl=en
>
> Check out the new CakePHP Questions sitehttp://cakeqs.organd 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 cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group 
> athttp://groups.google.com/group/cake-php?hl=en

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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to