First, to make sure that your association between Invoice and
InvoiceRow does not affect the issue solving, please comment it out in
your Invoice model!

Taking your example, finding invoices from within the Invoices
controller, then you must specify the Containable conditions as:

[code]
$this->Invoice->find(
   'all',
   array(
      'contain' => array(
         'Client' => array(
            'Country'
         )
      )
   )
);
[/code]

The reason is the Country is related through the Client. This will
mean that the Country record will be located inside the Client record.

Try it out and tell us what you got and whether it helped you on the
way :)
Enjoy,
   John

On Jun 6, 10:09 pm, Christopher Hanson <[email protected]> wrote:
> hey, i tried the following
>
> <?php
>
> class Invoice extends AppModel
> {
>
>      var $name = 'Invoice';
>      var $actAs = array('Containable');
>      var $hasMany = array(
>          'InvoiceRows' => array(
>              'className' => 'InvoiceRows',
>              'foreignKey' => 'invoice_id',
>              'order' => 'InvoiceRows.delta ASC',
>          ),
>      );
>      var $belongsTo = array(
>          'Client' => array(
>              'className' => 'Client',
>          ),
>      );
>
> }
>
> and
>
> <?php
>
> class InvoicesController extends AppController
> {
>
>      var $name = 'Invoices';
>
>      function index(){}
>
>      function view($invoice_id)
>      {
>
>          $this->Invoice->contain('Country');
>          $data = $this->Invoice->find('all');
>          //$data = $this->Invoice->findById($invoice_id);
>          debug($data);
>          $this->set('client_data', $data);
>
>      }
>
> }
>
> also even if i try contain(); it still comes back with this error
>
> *Warning*  (512)  <javascript:void(0);>:*SQL Error:*  1064: You have an error 
> in your SQL syntax; check the manual that corresponds to your MySQL server 
> version for the right syntax to use near 'contain' at line 1  
> [*CORE\cake\libs\model\datasources\dbo_source.php*, line*673*]
>
> Chris
>
> --
> Best Regards Christopher Hanson

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