Table Products have a foreign key 'product_family_id' and have belongs to relationship with Product_families table. Table Product_families have foreign key 'customer_id' and have belongs to relationship with Customers table. Now How can i connect Product model and Customer model to have customer name in Product View.
On Wed, Jun 19, 2013 at 10:29 AM, Ravinder Kaur <[email protected]> wrote: > Yes I have model for all my tables.. > > > On Tue, Jun 18, 2013 at 7:25 PM, Eric Haskins <[email protected]> wrote: > >> Do you have a Customers Model? I have models for all of my tables >> >> >> >> >> On Monday, June 17, 2013 5:38:40 PM UTC-4, Raks wrote: >> >>> Returns an Error >>> >>> {"code":500,"url":"\/products\**/listing_data.json","name":"**Call to a >>> member function find() on a non-object"} >>> >>> >>> >>> On Mon, Jun 17, 2013 at 1:26 PM, Gaurav Matta <[email protected]>wrote: >>> >>>> If you only want name of customers then you can add public $uses= >>>> array('product','customer'); as a datamember in your controller class >>>> >>>> And you can use $this->customer->find('all') in ur action >>>> >>>> Let me know if this helps >>>> On 17-Jun-2013 11:08 PM, "Raks" <[email protected]> wrote: >>>> >>>>> Have added a new Column... but m not able to get a column data from >>>>> other model. I want name from customers table in products view.ctp. >>>>> >>>>> here's the view code: >>>>> *<?php >>>>> $records = array(); >>>>> foreach ($products as $product){ >>>>> >>>>> $status = ($product['Product']['is_active'] == '1') ? 'Enabled' : >>>>> 'Disabled'; >>>>> >>>>> $records[] = array( >>>>> 'Product.model' => array('title' => >>>>> $product['Product']['model'], 'id' => $product['Product']['id']), >>>>> 'Product.part_num' => >>>>> $product['Product']['part_num'], >>>>> 'ProductFamily.name' => >>>>> $product['ProductFamily']['name'], >>>>> // shows customer id.. but want customer >>>>> name from customers table according to customer id. >>>>> //'Customer.name'=>$product['ProductFamily']['customer_id'], >>>>> 'Product.iron_oem' => >>>>> ($product['Product']['iron_oem']) ? 'Iron Systems':'Third Party', >>>>> 'ProductType.title' => >>>>> $product['ProductType']['title'], >>>>> 'Product.is_active' => $status, >>>>> ); >>>>> } >>>>> >>>>> $data = json_encode($records); >>>>> $ret = "{data:" . $data .",\n"; >>>>> $ret .= "pageInfo:{totalRowNum:" . $total . "},\n"; >>>>> $ret .= "recordType : 'array'}"; >>>>> echo $ret; >>>>> ?>* >>>>> On Friday, June 7, 2013 11:40:19 AM UTC-7, Raks wrote: >>>>>> >>>>>> Hi, >>>>>> >>>>>> I Have a piece of code having view, model and controller . I nee dto >>>>>> make changes to view only not in the database. >>>>>> So how can i do that. Do I need to edit model and controller as well. >>>>>> I am new to Cakephp and MVC framework too. >>>>>> >>>>>> Thanks. >>>>>> >>>>> -- >>>>> Like Us on FaceBook >>>>> https://www.facebook.com/**CakePHP<https://www.facebook.com/CakePHP> >>>>> Find us on Twitter http://twitter.com/CakePHP >>>>> >>>>> --- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "CakePHP" group. >>>>> To unsubscribe from this group and stop receiving emails from it, send >>>>> an email to cake-php+u...@**googlegroups.com. >>>>> >>>>> To post to this group, send email to [email protected]. >>>>> >>>>> Visit this group at >>>>> http://groups.google.com/**group/cake-php<http://groups.google.com/group/cake-php> >>>>> . >>>>> For more options, visit >>>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out> >>>>> . >>>>> >>>>> >>>>> >>>> -- >>>> Like Us on FaceBook >>>> https://www.facebook.com/**CakePHP<https://www.facebook.com/CakePHP> >>>> Find us on Twitter http://twitter.com/CakePHP >>>> >>>> --- >>>> You received this message because you are subscribed to a topic in the >>>> Google Groups "CakePHP" group. >>>> To unsubscribe from this topic, visit https://groups.google.com/d/** >>>> topic/cake-php/2KJFo4Ix7Ew/**unsubscribe<https://groups.google.com/d/topic/cake-php/2KJFo4Ix7Ew/unsubscribe> >>>> . >>>> To unsubscribe from this group and all its topics, send an email to >>>> cake-php+u...@**googlegroups.com. >>>> To post to this group, send email to [email protected]. >>>> >>>> Visit this group at >>>> http://groups.google.com/**group/cake-php<http://groups.google.com/group/cake-php> >>>> . >>>> For more options, visit >>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out> >>>> . >>>> >>>> >>>> >>> >>> >>> >>> -- >>> -------*Ravinder Kaur*-------- >>> >> -- >> Like Us on FaceBook https://www.facebook.com/CakePHP >> Find us on Twitter http://twitter.com/CakePHP >> >> --- >> You received this message because you are subscribed to a topic in the >> Google Groups "CakePHP" group. >> To unsubscribe from this topic, visit >> https://groups.google.com/d/topic/cake-php/2KJFo4Ix7Ew/unsubscribe. >> To unsubscribe from this group and all its topics, send an email to >> [email protected]. >> To post to this group, send email to [email protected]. >> Visit this group at http://groups.google.com/group/cake-php. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > > > > -- > -------*Ravinder Kaur*-------- > -- -------*Ravinder Kaur*-------- -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
