Re: Problem with models....help please!!!
On 07/06/2010 08:46, dtemes wrote: I think you have a typo: var $actAs = array('Containable'); should be var $actsAs = array('Containable'); you forgot the 's' On 6 jun, 21:09, Christopher Hanson wrote: hey, i tried the following array( 'className' => 'InvoiceRows', 'foreignKey' => 'invoice_id', 'order' => 'InvoiceRows.delta ASC', ), ); var $belongsTo = array( 'Client' => array( 'className' => 'Client', ), ); } and 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):*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 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 thanks detemes, noticed this already last night and changed it and it worked. until changed couldnt see why wasnt working lol thanks -- 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 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
Re: Problem with models....help please!!!
On 06/06/2010 20:18, Jens Ulf Dittrich wrote: I guess you have no Class "InvoiceRows" in your Models. I think your Invoice AppModel should be something like: ... var $hasMany = array( 'InvoiceRows' => array( // I guess that is ok for the name 'className' => 'Invoice', // <-- this one has to be a name of an actually existing Model/Table . Hi Jens InvoiceRows works fine alrready, i Have classname as InvoiceRows, a table in db invoice_rows and model file invoice_rows.php but thanks for the help anyway. -- 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 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
Re: Problem with models....help please!!!
On 06/06/2010 20:28, John Andersen wrote: 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 wrote: hey, i tried the following array( 'className' => 'InvoiceRows', 'foreignKey' => 'invoice_id', 'order' => 'InvoiceRows.delta ASC', ), ); var $belongsTo = array( 'Client' => array( 'className' => 'Client', ), ); } and 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):*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 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 i do have it working now, is noticed a mistake in invoice.php, $asctAs instead of $actsAs, i now get countries, do you know how to display the Country data in the same way on the client data so i can keep same variable access? thanks -- 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 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
Re: Problem with models....help please!!!
thanks John, tried that but still doesnt fetch any country data, im really not sure where the problem is :( any other suggestions? thanks -- 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 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
Re: Problem with models....help please!!!
hey, i tried the following array( 'className' => 'InvoiceRows', 'foreignKey' => 'invoice_id', 'order' => 'InvoiceRows.delta ASC', ), ); var $belongsTo = array( 'Client' => array( 'className' => 'Client', ), ); } and 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) :*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 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
Re: Problem with models....help please!!!
On 06/06/2010 19:51, John Andersen wrote: Have you added the Containable behavior to your model(s) or even better to the AppModel? Like: [code] var $actsAs = array('Containable'); [/code] Only after doing that, can you use it! If you have done it, then please show the code of your find statement including the contain conditions.. Enjoy, John On Jun 6, 9:34 pm, Christopher Hanson wrote: also i have been reading on containable and i just get SQL errors when i try to use either $this->Model->contain() or in the params for find, any ideas whats gong wrong? -- 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 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 Johndont beat me with a bati forgot that bit :D lol how would you suggest i get the country data pulling right in my invoice data? if you dont mind me askin thanks and ill try the above now. 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 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
Re: Problem with models....help please!!!
also i have been reading on containable and i just get SQL errors when i try to use either $this->Model->contain() or in the params for find, any ideas whats gong wrong? -- 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 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
Re: Problem with models....help please!!!
On 06/06/2010 18:54, John Andersen wrote: There is nothing wrong with your associations/relationships between the Invoice, Client and Country models. You just have to read up on the recursive attribute in the model, see: http://book.cakephp.org/view/1057/Model-Attributes#recursive-1063 That should give you a hint :) Next I suggest you study the Containable behavior, as that will make life easier for you in the future, with regard to finding related information. See: http://book.cakephp.org/view/1323/Containable Last I also suggest you conform to the CakePHP conventions, see: http://book.cakephp.org/view/901/CakePHP-Conventions Note specially the Model naming (hint: className => InvoicesRows)! Enjoy, John On Jun 6, 7:05 pm, "phpcoder2...@googlemail.com" wrote: 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 array( 'className' => 'InvoicesRows', 'foreignKey' => 'invoice_id', 'order' => 'InvoiceRows.delta ASC', ), ); var $belongsTo = array( 'Client' => array( 'className' => 'Client', ), ); } my client model 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 thanks for your reply John, id just stumbled upon recursive before thie email, its bringing my Country data but inside of the Client data, every where else im accessing it outside Client, so Client -> data, Country -> data but recursive is fetching Client -> data, Country. I though id changed InvoicesRow to InvoiceRows (thats better right?); guess i hadnt lol, thanks 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 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