Hey guys, new here so please be gentle ;) lol here is my issue i need
help getting my head around.

I have the following models

invoice.php
client.php
country.php

client has country_id in db which relates to id in the country table
and pulls the correct country. this pulls out by using belongsTo
country in my client model and works great! my problem now is when i
go into an invoice it pulls the the client because im using belongsTo
client in the invoice model and using hasMany invoices in my client
model, this works great except the invoice only pulls the client
details along with the invoice data and doesnt fetch the country...
can anyone help me?

heres the code too:

invoice model

<?php

class Invoice extends AppModel
{

    var $name = 'Invoice';
    var $hasMany = array(
        'InvoiceRows' => array(
            'className' => 'InvoicesRows',
            'foreignKey' => 'invoice_id',
            'order' => 'InvoiceRows.delta ASC',
        ),
    );
    var $belongsTo = array(
        'Client' => array(
            'className' => 'Client',
        ),
    );

}

my client model

<?php

class Client extends AppModel
{

    var $name = 'Client';
    var $hasMany = array(
        'Invoices' => array(
            'className' => 'Invoice',
            'foreignKey' => 'client_id',
            'order' => 'Invoices.invoice_no DESC',
        ),
    );
    var $belongsTo = array(
        'Country' => array(
            'className' => 'Country',
            'foreignKey' => 'country_id',
        ),
    );

}

can anyone see anything wrong?

thanks Chris

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