How to relate table with one of many others?
Hello, I have created a topic on stackoverflow but didn't get attention. So... I am little confused about my db design. I have orders table that may have records from one of many others. So is it OK to relate each tables with 1:1 to orders. Please look at orders domains andhostings table relations. My orders table rows has either a domain or hosting regarding to its orders_type value. There will be more than 10 products like domains, hostings etc. So creating a column on orders table for each product would not be a good practice. What is the best way to build my structure for CakePhp? https://lh3.googleusercontent.com/-AbWgKx7GQz0/Ukln-HZdS7I/ERI/_yO9gr7hiow/s1600/eer.JPG -- 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 cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
Re: How to relate table with one of many others?
Surely there would be a 1-many relationship between: orders_types (which ought to be called order_types) and orders domains to orders hostings to orders? Jeremy Burns Class Outfit http://www.classoutfit.com On 30 Sep 2013, at 13:05:18, Kemal ahmetkemala...@gmail.com wrote: Hello, I have created a topic on stackoverflow but didn't get attention. So... I am little confused about my db design. I have orders table that may have records from one of many others. So is it OK to relate each tables with 1:1 to orders. Please look at orders domains andhostings table relations. My orders table rows has either a domain or hosting regarding to its orders_type value. There will be more than 10 products like domains, hostings etc. So creating a column on orders table for each product would not be a good practice. What is the best way to build my structure for CakePhp? -- 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 cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out. -- 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 cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
Re: How to relate table with one of many others?
Scrub that - I see there is an orders_id field on hostings and domains. Sorry. However, some of your fields have incorrect names: domains-orders_id ought to be 'order_id' hostings-orders_id ought to be 'order_id' orders-orders_types_id ought to order_type_id clients_bills table name ought to be client_bills client_bills-clients_id ought to be client_id I note that you have both clients_id and client_id on the orders table. I'm assuming that one would be the id used by the client? If so, the joining field will be order_id. I'd consider renaming orders_id to something that doesn't end in _id as Cake will try to find a related table and build an association with it; perhaps client_reference would be better? If you made those changes you could get your basic models built using cake bake. Jeremy Burns Class Outfit http://www.classoutfit.com On 30 Sep 2013, at 13:23:25, Jeremy Burns | Class Outfit jeremybu...@classoutfit.com wrote: Surely there would be a 1-many relationship between: orders_types (which ought to be called order_types) and orders domains to orders hostings to orders? Jeremy Burns Class Outfit http://www.classoutfit.com On 30 Sep 2013, at 13:05:18, Kemal ahmetkemala...@gmail.com wrote: Hello, I have created a topic on stackoverflow but didn't get attention. So... I am little confused about my db design. I have orders table that may have records from one of many others. So is it OK to relate each tables with 1:1 to orders. Please look at orders domains andhostings table relations. My orders table rows has either a domain or hosting regarding to its orders_type value. There will be more than 10 products like domains, hostings etc. So creating a column on orders table for each product would not be a good practice. What is the best way to build my structure for CakePhp? -- 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 cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out. -- 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 cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out. -- 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 cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
Re: How to relate table with one of many others?
I am using Mysql Workbench and it forces plural names. I will fix them. Will cakephp decide whether it is a domain or a hosting looking by order_type_id? On Monday, September 30, 2013 3:35:15 PM UTC+3, Jeremy Burns wrote: Scrub that - I see there is an orders_id field on hostings and domains. Sorry. However, some of your fields have incorrect names: - domains-orders_id ought to be 'order_id' - hostings-orders_id ought to be 'order_id' - orders-orders_types_id ought to order_type_id - clients_bills table name ought to be client_bills - client_bills-clients_id ought to be client_id I note that you have both clients_id and client_id on the orders table. I'm assuming that one would be the id used by the client? If so, the joining field will be order_id. I'd consider renaming orders_id to something that doesn't end in _id as Cake will try to find a related table and build an association with it; perhaps client_reference would be better? If you made those changes you could get your basic models built using cake bake. Jeremy Burns Class Outfit http://www.classoutfit.com On 30 Sep 2013, at 13:23:25, Jeremy Burns | Class Outfit jerem...@classoutfit.com javascript: wrote: Surely there would be a 1-many relationship between: - orders_types (which ought to be called order_types) and orders - domains to orders - hostings to orders? Jeremy Burns Class Outfit http://www.classoutfit.com On 30 Sep 2013, at 13:05:18, Kemal ahmetke...@gmail.com javascript: wrote: Hello, I have created a topic on stackoverflow but didn't get attention. So... I am little confused about my db design. I have orders table that may have records from one of many others. So is it OK to relate each tables with 1:1 to orders. Please look at orders domains andhostings table relations. My orders table rows has either a domain or hosting regarding to its orders_type value. There will be more than 10 products like domains, hostings etc. So creating a column on orders table for each product would not be a good practice. What is the best way to build my structure for CakePhp? https://lh3.googleusercontent.com/-AbWgKx7GQz0/Ukln-HZdS7I/ERI/_yO9gr7hiow/s1600/eer.JPG -- 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 cake-php+u...@googlegroups.com javascript:. To post to this group, send email to cake...@googlegroups.comjavascript: . Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out. -- 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 cake-php+u...@googlegroups.com javascript:. To post to this group, send email to cake...@googlegroups.comjavascript: . Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out. -- 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 cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
Re: How to relate table with one of many others?
I am using Mysql Workbench and it forces plural names. I will fix them. Will cakephp decide whether it is a domain or a hosting looking by order_type_id? -- 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 cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
Re: How to relate table with one of many others?
I am using Mysql Workbench and it forces plural names. I will fix them. Will cakephp decide whether it is a domain or a hosting looking by order_type_id? On Monday, September 30, 2013 3:35:15 PM UTC+3, Jeremy Burns wrote: Scrub that - I see there is an orders_id field on hostings and domains. Sorry. However, some of your fields have incorrect names: - domains-orders_id ought to be 'order_id' - hostings-orders_id ought to be 'order_id' - orders-orders_types_id ought to order_type_id - clients_bills table name ought to be client_bills - client_bills-clients_id ought to be client_id I note that you have both clients_id and client_id on the orders table. I'm assuming that one would be the id used by the client? If so, the joining field will be order_id. I'd consider renaming orders_id to something that doesn't end in _id as Cake will try to find a related table and build an association with it; perhaps client_reference would be better? If you made those changes you could get your basic models built using cake bake. Jeremy Burns Class Outfit http://www.classoutfit.com On 30 Sep 2013, at 13:23:25, Jeremy Burns | Class Outfit jerem...@classoutfit.com javascript: wrote: Surely there would be a 1-many relationship between: - orders_types (which ought to be called order_types) and orders - domains to orders - hostings to orders? Jeremy Burns Class Outfit http://www.classoutfit.com On 30 Sep 2013, at 13:05:18, Kemal ahmetke...@gmail.com javascript: wrote: Hello, I have created a topic on stackoverflow but didn't get attention. So... I am little confused about my db design. I have orders table that may have records from one of many others. So is it OK to relate each tables with 1:1 to orders. Please look at orders domains andhostings table relations. My orders table rows has either a domain or hosting regarding to its orders_type value. There will be more than 10 products like domains, hostings etc. So creating a column on orders table for each product would not be a good practice. What is the best way to build my structure for CakePhp? https://lh3.googleusercontent.com/-AbWgKx7GQz0/Ukln-HZdS7I/ERI/_yO9gr7hiow/s1600/eer.JPG -- 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 cake-php+u...@googlegroups.com javascript:. To post to this group, send email to cake...@googlegroups.comjavascript: . Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out. -- 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 cake-php+u...@googlegroups.com javascript:. To post to this group, send email to cake...@googlegroups.comjavascript: . Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out. -- 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 cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
Re: How to relate table with one of many others?
Cake won't/can't but your code can make it happen. Jeremy Burns Class Outfit http://www.classoutfit.com On 30 Sep 2013, at 13:55:01, Kemal ahmetkemala...@gmail.com wrote: I am using Mysql Workbench and it forces plural names. I will fix them. Will cakephp decide whether it is a domain or a hosting looking by order_type_id? On Monday, September 30, 2013 3:35:15 PM UTC+3, Jeremy Burns wrote: Scrub that - I see there is an orders_id field on hostings and domains. Sorry. However, some of your fields have incorrect names: domains-orders_id ought to be 'order_id' hostings-orders_id ought to be 'order_id' orders-orders_types_id ought to order_type_id clients_bills table name ought to be client_bills client_bills-clients_id ought to be client_id I note that you have both clients_id and client_id on the orders table. I'm assuming that one would be the id used by the client? If so, the joining field will be order_id. I'd consider renaming orders_id to something that doesn't end in _id as Cake will try to find a related table and build an association with it; perhaps client_reference would be better? If you made those changes you could get your basic models built using cake bake. Jeremy Burns Class Outfit http://www.classoutfit.com On 30 Sep 2013, at 13:23:25, Jeremy Burns | Class Outfit jerem...@classoutfit.com wrote: Surely there would be a 1-many relationship between: orders_types (which ought to be called order_types) and orders domains to orders hostings to orders? Jeremy Burns Class Outfit http://www.classoutfit.com On 30 Sep 2013, at 13:05:18, Kemal ahmetke...@gmail.com wrote: Hello, I have created a topic on stackoverflow but didn't get attention. So... I am little confused about my db design. I have orders table that may have records from one of many others. So is it OK to relate each tables with 1:1 to orders. Please look at orders domains andhostings table relations. My orders table rows has either a domain or hosting regarding to its orders_type value. There will be more than 10 products like domains, hostings etc. So creating a column on orders table for each product would not be a good practice. What is the best way to build my structure for CakePhp? -- 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 cake-php+u...@googlegroups.com. To post to this group, send email to cake...@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out. -- 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 cake-php+u...@googlegroups.com. To post to this group, send email to cake...@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out. -- 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 cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out. -- 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 cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
Re: How to relate table with one of many others?
Thank you On Monday, September 30, 2013 5:39:42 PM UTC+3, Jeremy Burns wrote: Cake won't/can't but your code can make it happen. Jeremy Burns Class Outfit http://www.classoutfit.com On 30 Sep 2013, at 13:55:01, Kemal ahmetke...@gmail.com javascript: wrote: I am using Mysql Workbench and it forces plural names. I will fix them. Will cakephp decide whether it is a domain or a hosting looking by order_type_id? On Monday, September 30, 2013 3:35:15 PM UTC+3, Jeremy Burns wrote: Scrub that - I see there is an orders_id field on hostings and domains. Sorry. However, some of your fields have incorrect names: - domains-orders_id ought to be 'order_id' - hostings-orders_id ought to be 'order_id' - orders-orders_types_id ought to order_type_id - clients_bills table name ought to be client_bills - client_bills-clients_id ought to be client_id I note that you have both clients_id and client_id on the orders table. I'm assuming that one would be the id used by the client? If so, the joining field will be order_id. I'd consider renaming orders_id to something that doesn't end in _id as Cake will try to find a related table and build an association with it; perhaps client_reference would be better? If you made those changes you could get your basic models built using cake bake. Jeremy Burns Class Outfit http://www.classoutfit.com On 30 Sep 2013, at 13:23:25, Jeremy Burns | Class Outfit jerem...@classoutfit.com wrote: Surely there would be a 1-many relationship between: - orders_types (which ought to be called order_types) and orders - domains to orders - hostings to orders? Jeremy Burns Class Outfit http://www.classoutfit.com On 30 Sep 2013, at 13:05:18, Kemal ahmetke...@gmail.com wrote: Hello, I have created a topic on stackoverflow but didn't get attention. So... I am little confused about my db design. I have orders table that may have records from one of many others. So is it OK to relate each tables with 1:1 to orders. Please look at orders domains andhostings table relations. My orders table rows has either a domain or hosting regarding to its orders_type value. There will be more than 10 products like domains, hostings etc. So creating a column on orders table for each product would not be a good practice. What is the best way to build my structure for CakePhp? https://lh3.googleusercontent.com/-AbWgKx7GQz0/Ukln-HZdS7I/ERI/_yO9gr7hiow/s1600/eer.JPG -- 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 cake-php+u...@googlegroups.com. To post to this group, send email to cake...@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out. -- 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 cake-php+u...@googlegroups.com. To post to this group, send email to cake...@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out. -- 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 cake-php+u...@googlegroups.com javascript:. To post to this group, send email to cake...@googlegroups.comjavascript: . Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out. -- 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 cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
Re: Is nested one-to-many table relationships possible in CakePHP?
The short answer is Yes as CakePHP supports nearly whatever relationships you design in your database. You relationships are as this: Table1 - hasMany - Table2 - hasMany - Table3 With CakePHP you can find data from Table1 alone, from Table1 including Table2, and also from Table1 including Table2 including Table3 - as your data is related. Suggest you to take a look at the Model and the ModelHelper Contains in the CakePHP book/documentation. Enjoy, John On Friday, 6 September 2013 05:13:37 UTC+3, Sam wrote: Dear CakePHP experts, While designing a database structure, I created 3 tables. There is a 1-to-many relationship between the first table and second table. There is another 1-to-many relationship between the second table and third table. Does CakePHP allow this kind of table relationship? I hope this does not sound like a stupid question to the experts here. -- 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 cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
Re: Is nested one-to-many table relationships possible in CakePHP?
Correction to this part: Suggest you to take a look at the Model and the ModelHelper Contains in the CakePHP book/documentation. Should be: Suggest you to take a look at the Model and the Behaviour Containable in the CakePHP book/documentation. Enjoy, John -- 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 cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
Is nested one-to-many table relationships possible in CakePHP?
Dear CakePHP experts, While designing a database structure, I created 3 tables. There is a 1-to-many relationship between the first table and second table. There is another 1-to-many relationship between the second table and third table. Does CakePHP allow this kind of table relationship? I hope this does not sound like a stupid question to the experts here. -- 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 cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
Re: Is nested one-to-many table relationships possible in CakePHP?
class FirstModel extends AppModel { public $hasOne = array('Second'); public $hasMany = array('Third'); } class SecondModel extend AppModel { public $belongsTo = array('First'); } class ThirdModel extend AppModel { public $belongsTo = array('First'); } On Fri, Sep 6, 2013 at 10:13 AM, Sam lightai...@gmail.com wrote: Dear CakePHP experts, While designing a database structure, I created 3 tables. There is a 1-to-many relationship between the first table and second table. There is another 1-to-many relationship between the second table and third table. Does CakePHP allow this kind of table relationship? I hope this does not sound like a stupid question to the experts here. -- 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 cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out. -- Simon Males -- 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 cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
Re: Storing arrays in the database (one field many values)
i need to move selected images to img/gallery/..i could able to select more than one images...instead more images there is only one image uploaded in that folder..is there a way to solve this issue..thanks in advance echo $form-create('Image', array('action' = 'save' ,'type' = 'file','multiple'='multiple')); //echo $form-file('File'); echo $form-file('File', array('type' = 'file','multiple' = 'multiple')); echo $form-hidden(v_id,array (value=$this-data['Image']['v_id'])); echo $form-submit('Upload'); echo $form-end(); -- 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 post to this group, send email to cake-php@googlegroups.com. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php?hl=en.
Creating an interface for a one-to-many interface.
I have two models set up, LearningExperience and Project. One LearningExperience can have many Projects. I'm building an interface for adding and for editing LearningExperiences. So far, when adding or editing a LearningExperience, I'm planning on having a button that opens a modal window. In the modal window will be a short form for adding a new Project, and when it is closed it sends the data via Ajax, updates the database, then populates a list on the LearningExperience page with the new project. This makes sense on the Edit page, where I already have the LearningExperience in the database and therefore an ID to associate the new Project to. But how do I go about saving a new Project on a new LearningExperience, when I don't have an ID for the LearningExperience yet? Thanks! -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
A One To Many, and a One to One relationship between the same two tables?
Hey Guys, So, I have an application I'm working on to automate deployment of my SaaS applications (We have quite a few), and we have an applications table that defines the different offerings we have, and an application_versions table that has each release (minor and major) for each application. We want one application_version to be the one used when a customer purchases a new product. The application_versions to applications one to many relationship is a piece of cake obviously. While I could just add a flag to the application_versions table that says latest or something like that, I'd prefer to put it as a relationship directly on the application record. Is there a naming convention for adding a relationship like this? I.e. instead of just adding application_version_id to the application table, can I do latest_stable_application_version_id or something like that? Thanks! Joey -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: A One To Many, and a One to One relationship between the same two tables?
id | application_id | version find - last El 10 de marzo de 2012 15:59, Joey Novak j...@novaksolutions.com escribió: Hey Guys, So, I have an application I'm working on to automate deployment of my SaaS applications (We have quite a few), and we have an applications table that defines the different offerings we have, and an application_versions table that has each release (minor and major) for each application. We want one application_version to be the one used when a customer purchases a new product. The application_versions to applications one to many relationship is a piece of cake obviously. While I could just add a flag to the application_versions table that says latest or something like that, I'd prefer to put it as a relationship directly on the application record. Is there a naming convention for adding a relationship like this? I.e. instead of just adding application_version_id to the application table, can I do latest_stable_application_version_id or something like that? Thanks! Joey -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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 -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: simple one-to-many question
i dont hv any view yet, i m trying scaffold... On Fri, Dec 3, 2010 at 6:48 PM, Bogdan Bursuc bogdanbursu...@gmail.com wrote: You must set to the view the variable called authors like so $this-set('authors', $this-Book-Authors-find('list')); Cake FormHelper transforms key_id in to a select and he is looking for a variable called authors in your view to populate that select. On Fri, Dec 3, 2010 at 11:08 AM, Hans Wiriya Tsai hansw...@gmail.com wrote: i m trying to make a relation between 2 tables: Authors that hasMany Books. So I created those 2 tables and one additional field author_id in Books table as foreign key to Authors. Next I create Author model that hasMany = Book and Book model that belongsTo Author. And then on both controller I put scaffold. Now I can add Author without problem via http://localhost/authors/add. Then if I browse to http://localhost/books/add, the form shows but the dropdown list which is supposed to be a list of author won't show. The list is empty. Any clue? I thought scaffold should create the relation automatically... or perhaps i miss something? 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, Bogdan Iulian Bursuc 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 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: simple one-to-many question
that's not the issue Ryan, it's only an example... i do know that books could have more than one author :) On Fri, Dec 3, 2010 at 9:23 PM, Ryan Schmidt google-2...@ryandesign.com wrote: On Dec 3, 2010, at 03:08, Hans Wiriya Tsai wrote: i m trying to make a relation between 2 tables: Authors that hasMany Books. Don't some books have more than one author? :) 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 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
simple one-to-many question
i m trying to make a relation between 2 tables: Authors that hasMany Books. So I created those 2 tables and one additional field author_id in Books table as foreign key to Authors. Next I create Author model that hasMany = Book and Book model that belongsTo Author. And then on both controller I put scaffold. Now I can add Author without problem via http://localhost/authors/add. Then if I browse to http://localhost/books/add, the form shows but the dropdown list which is supposed to be a list of author won't show. The list is empty. Any clue? I thought scaffold should create the relation automatically... or perhaps i miss something? 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: simple one-to-many question
You must set to the view the variable called authors like so $this-set('authors', $this-Book-Authors-find('list')); Cake FormHelper transforms key_id in to a select and he is looking for a variable called authors in your view to populate that select. On Fri, Dec 3, 2010 at 11:08 AM, Hans Wiriya Tsai hansw...@gmail.com wrote: i m trying to make a relation between 2 tables: Authors that hasMany Books. So I created those 2 tables and one additional field author_id in Books table as foreign key to Authors. Next I create Author model that hasMany = Book and Book model that belongsTo Author. And then on both controller I put scaffold. Now I can add Author without problem via http://localhost/authors/add. Then if I browse to http://localhost/books/add, the form shows but the dropdown list which is supposed to be a list of author won't show. The list is empty. Any clue? I thought scaffold should create the relation automatically... or perhaps i miss something? 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, Bogdan Iulian Bursuc 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: simple one-to-many question
On Dec 3, 2010, at 03:08, Hans Wiriya Tsai wrote: i m trying to make a relation between 2 tables: Authors that hasMany Books. Don't some books have more than one author? :) 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: Data validation: check whether at least one of many fields has a value?
Thanks for this useful hint, euromark! On Tue, Sep 7, 2010 at 5:04 PM, euromark dereurom...@googlemail.com wrote: if would use !empty() !!! because the fields can be empty strings and will still pass validation On 7 Sep., 16:59, Joshua Muheim psybea...@gmail.com wrote: Thank you! :-) On Tue, Sep 7, 2010 at 3:12 PM, Jeremy Burns | Class Outfit jeremybu...@classoutfit.com wrote: Here's an example: The validation rule is: 'phone_home' = array( 'hasOnePhone' = array( 'rule' = 'hasOnePhone', 'message' = 'You must enter at least one phone number.', 'last' = true ) ), The model function is: function hasOnePhone() { if ( $this-data['address']['phone_home'] != null || $this-data['address']['phone_work'] != null || $this-data['address']['phone_cell'] != null ): return true; endif; } Jeremy Burns Class Outfit jeremybu...@classoutfit.com http://www.classoutfit.com On 7 Sep 2010, at 13:57, psybear83 wrote: Hi all I'm seeing how to have many validation rules for one field everywhere, but I couldn't figure out how to have on validation rule that depends on many fields?! I have a model with 3 fields. I want to check that at least one of these fields has a value. How can I achieve this? Thanks, Josh 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 at http://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 at http://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 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: Data validation: check whether at least one of many fields has a value?
Another question: is there a way to display the error message not in one of the checked fields? Because it applies to all the fields (phone_home AND phone_work AND phone_cell), not just one (phone_home in the posted example)... Thanks :-) On Wed, Sep 8, 2010 at 9:16 AM, Joshua Muheim psybea...@gmail.com wrote: Thanks for this useful hint, euromark! On Tue, Sep 7, 2010 at 5:04 PM, euromark dereurom...@googlemail.com wrote: if would use !empty() !!! because the fields can be empty strings and will still pass validation On 7 Sep., 16:59, Joshua Muheim psybea...@gmail.com wrote: Thank you! :-) On Tue, Sep 7, 2010 at 3:12 PM, Jeremy Burns | Class Outfit jeremybu...@classoutfit.com wrote: Here's an example: The validation rule is: 'phone_home' = array( 'hasOnePhone' = array( 'rule' = 'hasOnePhone', 'message' = 'You must enter at least one phone number.', 'last' = true ) ), The model function is: function hasOnePhone() { if ( $this-data['address']['phone_home'] != null || $this-data['address']['phone_work'] != null || $this-data['address']['phone_cell'] != null ): return true; endif; } Jeremy Burns Class Outfit jeremybu...@classoutfit.com http://www.classoutfit.com On 7 Sep 2010, at 13:57, psybear83 wrote: Hi all I'm seeing how to have many validation rules for one field everywhere, but I couldn't figure out how to have on validation rule that depends on many fields?! I have a model with 3 fields. I want to check that at least one of these fields has a value. How can I achieve this? Thanks, Josh 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 at http://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 at http://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 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
Data validation: check whether at least one of many fields has a value?
Hi all I'm seeing how to have many validation rules for one field everywhere, but I couldn't figure out how to have on validation rule that depends on many fields?! I have a model with 3 fields. I want to check that at least one of these fields has a value. How can I achieve this? Thanks, Josh 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: Data validation: check whether at least one of many fields has a value?
Here's an example: The validation rule is: 'phone_home' = array( 'hasOnePhone' = array( 'rule' = 'hasOnePhone', 'message' = 'You must enter at least one phone number.', 'last' = true ) ), The model function is: function hasOnePhone() { if ( $this-data['address']['phone_home'] != null || $this-data['address']['phone_work'] != null || $this-data['address']['phone_cell'] != null ): return true; endif; } Jeremy Burns Class Outfit jeremybu...@classoutfit.com http://www.classoutfit.com On 7 Sep 2010, at 13:57, psybear83 wrote: Hi all I'm seeing how to have many validation rules for one field everywhere, but I couldn't figure out how to have on validation rule that depends on many fields?! I have a model with 3 fields. I want to check that at least one of these fields has a value. How can I achieve this? Thanks, Josh 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 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: Data validation: check whether at least one of many fields has a value?
Thank you! :-) On Tue, Sep 7, 2010 at 3:12 PM, Jeremy Burns | Class Outfit jeremybu...@classoutfit.com wrote: Here's an example: The validation rule is: 'phone_home' = array( 'hasOnePhone' = array( 'rule' = 'hasOnePhone', 'message' = 'You must enter at least one phone number.', 'last' = true ) ), The model function is: function hasOnePhone() { if ( $this-data['address']['phone_home'] != null || $this-data['address']['phone_work'] != null || $this-data['address']['phone_cell'] != null ): return true; endif; } Jeremy Burns Class Outfit jeremybu...@classoutfit.com http://www.classoutfit.com On 7 Sep 2010, at 13:57, psybear83 wrote: Hi all I'm seeing how to have many validation rules for one field everywhere, but I couldn't figure out how to have on validation rule that depends on many fields?! I have a model with 3 fields. I want to check that at least one of these fields has a value. How can I achieve this? Thanks, Josh 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 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 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: Data validation: check whether at least one of many fields has a value?
if would use !empty() !!! because the fields can be empty strings and will still pass validation On 7 Sep., 16:59, Joshua Muheim psybea...@gmail.com wrote: Thank you! :-) On Tue, Sep 7, 2010 at 3:12 PM, Jeremy Burns | Class Outfit jeremybu...@classoutfit.com wrote: Here's an example: The validation rule is: 'phone_home' = array( 'hasOnePhone' = array( 'rule' = 'hasOnePhone', 'message' = 'You must enter at least one phone number.', 'last' = true ) ), The model function is: function hasOnePhone() { if ( $this-data['address']['phone_home'] != null || $this-data['address']['phone_work'] != null || $this-data['address']['phone_cell'] != null ): return true; endif; } Jeremy Burns Class Outfit jeremybu...@classoutfit.com http://www.classoutfit.com On 7 Sep 2010, at 13:57, psybear83 wrote: Hi all I'm seeing how to have many validation rules for one field everywhere, but I couldn't figure out how to have on validation rule that depends on many fields?! I have a model with 3 fields. I want to check that at least one of these fields has a value. How can I achieve this? Thanks, Josh 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 at http://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 at http://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
Re: Updating One-to-Many Relations
I think the exception is when you have a many-to-many relationship and the 'unique' property is set (by default). Then it will delete all of the associated records in the join table before performing the add operations. On Jun 3, 7:21 am, John Andersen j.andersen...@gmail.com wrote: The saveAll only saves the information that is available, it does not remove information not available, so when you uncheck a Day, that information is not available and saveAll does nothing with it! You have to think differently in order to remove an existing Day :) Enjoy, John On Jun 3, 4:18 pm, bowikaxu bowik...@gmail.com wrote: Hi, i have a problem with a one to many relations, my models look like this: Calendar ( hasMany Days ) Day ( belongsTo Calendar ) The add operation is ok, i select some days from a calendar and they get inserted and related to its calendar. But when i edit a calendar the view previously selects the days it has, but if i remove one day and select another one and i do a saveAll operation the Days related to the Calendar remains the same, what could be wrong? Thanks in advance to all responses. 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
Updating One-to-Many Relations
Hi, i have a problem with a one to many relations, my models look like this: Calendar ( hasMany Days ) Day ( belongsTo Calendar ) The add operation is ok, i select some days from a calendar and they get inserted and related to its calendar. But when i edit a calendar the view previously selects the days it has, but if i remove one day and select another one and i do a saveAll operation the Days related to the Calendar remains the same, what could be wrong? Thanks in advance to all responses. 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: Updating One-to-Many Relations
The saveAll only saves the information that is available, it does not remove information not available, so when you uncheck a Day, that information is not available and saveAll does nothing with it! You have to think differently in order to remove an existing Day :) Enjoy, John On Jun 3, 4:18 pm, bowikaxu bowik...@gmail.com wrote: Hi, i have a problem with a one to many relations, my models look like this: Calendar ( hasMany Days ) Day ( belongsTo Calendar ) The add operation is ok, i select some days from a calendar and they get inserted and related to its calendar. But when i edit a calendar the view previously selects the days it has, but if i remove one day and select another one and i do a saveAll operation the Days related to the Calendar remains the same, what could be wrong? Thanks in advance to all responses. 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
One to Many question
Hello. I don't know if I'm doing things well, so I'll fire my question. I have a model relationship this way: Student hasMany ForeignSchool. First, I'll show my scenario, files and relevant code, then I'll explain the problem. SCENARIO: * Model file student.php (hasmany declaration): var $hasMany = array( 'ForeignSchool' = array( 'className' = 'ForeignSchool', 'foreignKey' = 'student_id', 'dependent' = true, ), ); * Model file foreign_school.php (belongsto declaration): var $belongsTo = array( 'Student' = array( 'className' = 'Student', 'foreignKey' = 'student_id', ), ); * Controller file students_controller.php (find call test): $this-Student-id = 2; //test hard code $foreignSchools = $this-Student-ForeignSchool-find('all'); $this-set(compact('foreignSchools')); * And in the corresponding view file: print_r($foreignSchools); PROBLEM: The call to print_r($foreignSchools) is showing all the foreign schools but not the schools of the current Student. Is it something I'm missing that is avoiding the filtering of the foreign schools shown in the view? Thanks a lot! 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: One to Many question
I'd try this: $foreignSchools = $this-Student-ForeignSchool-find('all', array('conditions' = array('ForeignSchool.student_id' = 2))); (hope the number of brackets is right...) Jeremy Burns jeremybu...@me.com On 3 Jun 2010, at 05:51, Roland Pish wrote: Hello. I don't know if I'm doing things well, so I'll fire my question. I have a model relationship this way: Student hasMany ForeignSchool. First, I'll show my scenario, files and relevant code, then I'll explain the problem. SCENARIO: * Model file student.php (hasmany declaration): var $hasMany = array( 'ForeignSchool' = array( 'className' = 'ForeignSchool', 'foreignKey' = 'student_id', 'dependent' = true, ), ); * Model file foreign_school.php (belongsto declaration): var $belongsTo = array( 'Student' = array( 'className' = 'Student', 'foreignKey' = 'student_id', ), ); * Controller file students_controller.php (find call test): $this-Student-id = 2; //test hard code $foreignSchools = $this-Student-ForeignSchool-find('all'); $this-set(compact('foreignSchools')); * And in the corresponding view file: print_r($foreignSchools); PROBLEM: The call to print_r($foreignSchools) is showing all the foreign schools but not the schools of the current Student. Is it something I'm missing that is avoiding the filtering of the foreign schools shown in the view? Thanks a lot! 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 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: One to Many question
You need to specify your conditions as part of the find, or get associated records from a Student model find. I'd personally do this with the containable behavior. Add the 'Containable' behavior to your models. I normally add this to my AppModel (/app/app_model.php), as I use it everywhere. Set $recursive to -1. Again, I do this on my app model: public $recursive = -1; In your StudentsController you can do the following: $id = 2; $student = $this-Student-find('all', array( 'conditions' = array('Student.id' = $id), 'contain' = array('ForeignSchool') )); $this-set(compact('student')); Now your data is available in $student in your view. Your foreign schools are at: $student['ForeignSchool] Hope that helps. Cheers, Graham Weldon (AKA: Predominant) On Thu, Jun 3, 2010 at 2:51 PM, Roland Pish rolandp...@gmail.com wrote: Hello. I don't know if I'm doing things well, so I'll fire my question. I have a model relationship this way: Student hasMany ForeignSchool. First, I'll show my scenario, files and relevant code, then I'll explain the problem. SCENARIO: * Model file student.php (hasmany declaration): var $hasMany = array( 'ForeignSchool' = array( 'className' = 'ForeignSchool', 'foreignKey' = 'student_id', 'dependent' = true, ), ); * Model file foreign_school.php (belongsto declaration): var $belongsTo = array( 'Student' = array( 'className' = 'Student', 'foreignKey' = 'student_id', ), ); * Controller file students_controller.php (find call test): $this-Student-id = 2; //test hard code $foreignSchools = $this-Student-ForeignSchool-find('all'); $this-set(compact('foreignSchools')); * And in the corresponding view file: print_r($foreignSchools); PROBLEM: The call to print_r($foreignSchools) is showing all the foreign schools but not the schools of the current Student. Is it something I'm missing that is avoiding the filtering of the foreign schools shown in the view? Thanks a lot! 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 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: One to Many question
Thanks for your reply Jeremy. I was avoiding the conditions array because I thought cake would do the magic and the automatic filter. In this specific case does cake do this magic? or is it neccesary to pass the conditions array? Regards. On 2 jun, 22:56, Jeremy Burns jeremybu...@me.com wrote: I'd try this: $foreignSchools = $this-Student-ForeignSchool-find('all', array('conditions' = array('ForeignSchool.student_id' = 2))); (hope the number of brackets is right...) Jeremy Burns jeremybu...@me.com On 3 Jun 2010, at 05:51, Roland Pish wrote: Hello. I don't know if I'm doing things well, so I'll fire my question. I have a model relationship this way: Student hasMany ForeignSchool. First, I'll show my scenario, files and relevant code, then I'll explain the problem. SCENARIO: * Model file student.php (hasmany declaration): var $hasMany = array( 'ForeignSchool' = array( 'className' = 'ForeignSchool', 'foreignKey' = 'student_id', 'dependent' = true, ), ); * Model file foreign_school.php (belongsto declaration): var $belongsTo = array( 'Student' = array( 'className' = 'Student', 'foreignKey' = 'student_id', ), ); * Controller file students_controller.php (find call test): $this-Student-id = 2; //test hard code $foreignSchools = $this-Student-ForeignSchool-find('all'); $this-set(compact('foreignSchools')); * And in the corresponding view file: print_r($foreignSchools); PROBLEM: The call to print_r($foreignSchools) is showing all the foreign schools but not the schools of the current Student. Is it something I'm missing that is avoiding the filtering of the foreign schools shown in the view? Thanks a lot! 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
Re: One to Many question
Graham's reply was far more comprehensive than mine and I'd go with it. I use containable as a matter of course. Jeremy Burns jeremybu...@me.com On 3 Jun 2010, at 06:01, Roland Pish wrote: Thanks for your reply Jeremy. I was avoiding the conditions array because I thought cake would do the magic and the automatic filter. In this specific case does cake do this magic? or is it neccesary to pass the conditions array? Regards. On 2 jun, 22:56, Jeremy Burns jeremybu...@me.com wrote: I'd try this: $foreignSchools = $this-Student-ForeignSchool-find('all', array('conditions' = array('ForeignSchool.student_id' = 2))); (hope the number of brackets is right...) Jeremy Burns jeremybu...@me.com On 3 Jun 2010, at 05:51, Roland Pish wrote: Hello. I don't know if I'm doing things well, so I'll fire my question. I have a model relationship this way: Student hasMany ForeignSchool. First, I'll show my scenario, files and relevant code, then I'll explain the problem. SCENARIO: * Model file student.php (hasmany declaration): var $hasMany = array( 'ForeignSchool' = array( 'className' = 'ForeignSchool', 'foreignKey' = 'student_id', 'dependent' = true, ), ); * Model file foreign_school.php (belongsto declaration): var $belongsTo = array( 'Student' = array( 'className' = 'Student', 'foreignKey' = 'student_id', ), ); * Controller file students_controller.php (find call test): $this-Student-id = 2; //test hard code $foreignSchools = $this-Student-ForeignSchool-find('all'); $this-set(compact('foreignSchools')); * And in the corresponding view file: print_r($foreignSchools); PROBLEM: The call to print_r($foreignSchools) is showing all the foreign schools but not the schools of the current Student. Is it something I'm missing that is avoiding the filtering of the foreign schools shown in the view? Thanks a lot! 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 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: One to Many question
Thanks Graham! So, this conditions array is mandatory in find method right? Regards On 2 jun, 23:01, Roland Pish rolandp...@gmail.com wrote: Thanks for your reply Jeremy. I was avoiding the conditions array because I thought cake would do the magic and the automatic filter. In this specific case does cake do this magic? or is it neccesary to pass the conditions array? Regards. On 2 jun, 22:56, Jeremy Burns jeremybu...@me.com wrote: I'd try this: $foreignSchools = $this-Student-ForeignSchool-find('all', array('conditions' = array('ForeignSchool.student_id' = 2))); (hope the number of brackets is right...) Jeremy Burns jeremybu...@me.com On 3 Jun 2010, at 05:51, Roland Pish wrote: Hello. I don't know if I'm doing things well, so I'll fire my question. I have a model relationship this way: Student hasMany ForeignSchool. First, I'll show my scenario, files and relevant code, then I'll explain the problem. SCENARIO: * Model file student.php (hasmany declaration): var $hasMany = array( 'ForeignSchool' = array( 'className' = 'ForeignSchool', 'foreignKey' = 'student_id', 'dependent' = true, ), ); * Model file foreign_school.php (belongsto declaration): var $belongsTo = array( 'Student' = array( 'className' = 'Student', 'foreignKey' = 'student_id', ), ); * Controller file students_controller.php (find call test): $this-Student-id = 2; //test hard code $foreignSchools = $this-Student-ForeignSchool-find('all'); $this-set(compact('foreignSchools')); * And in the corresponding view file: print_r($foreignSchools); PROBLEM: The call to print_r($foreignSchools) is showing all the foreign schools but not the schools of the current Student. Is it something I'm missing that is avoiding the filtering of the foreign schools shown in the view? Thanks a lot! 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 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: One to Many question
Ok, got it. I'll go for this containable behaviour right now. Thanks for you replies guys. Regards On 2 jun, 23:03, Roland Pish rolandp...@gmail.com wrote: Thanks Graham! So, this conditions array is mandatory in find method right? Regards On 2 jun, 23:01, Roland Pish rolandp...@gmail.com wrote: Thanks for your reply Jeremy. I was avoiding the conditions array because I thought cake would do the magic and the automatic filter. In this specific case does cake do this magic? or is it neccesary to pass the conditions array? Regards. On 2 jun, 22:56, Jeremy Burns jeremybu...@me.com wrote: I'd try this: $foreignSchools = $this-Student-ForeignSchool-find('all', array('conditions' = array('ForeignSchool.student_id' = 2))); (hope the number of brackets is right...) Jeremy Burns jeremybu...@me.com On 3 Jun 2010, at 05:51, Roland Pish wrote: Hello. I don't know if I'm doing things well, so I'll fire my question. I have a model relationship this way: Student hasMany ForeignSchool. First, I'll show my scenario, files and relevant code, then I'll explain the problem. SCENARIO: * Model file student.php (hasmany declaration): var $hasMany = array( 'ForeignSchool' = array( 'className' = 'ForeignSchool', 'foreignKey' = 'student_id', 'dependent' = true, ), ); * Model file foreign_school.php (belongsto declaration): var $belongsTo = array( 'Student' = array( 'className' = 'Student', 'foreignKey' = 'student_id', ), ); * Controller file students_controller.php (find call test): $this-Student-id = 2; //test hard code $foreignSchools = $this-Student-ForeignSchool-find('all'); $this-set(compact('foreignSchools')); * And in the corresponding view file: print_r($foreignSchools); PROBLEM: The call to print_r($foreignSchools) is showing all the foreign schools but not the schools of the current Student. Is it something I'm missing that is avoiding the filtering of the foreign schools shown in the view? Thanks a lot! Check out the new CakePHP Questions sitehttp://cakeqs.organdhelpothers 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
Re: one to many Model relations
Well, the situation is like this: Locations(id, location_info) is an independent table to store all relevant locations. Jobs (id, name, location_id) is a table that has exactly one location for each job, and stores the location_id from location(id). Shops(id, name, location_id) is another table that has exactly one location for each shop, and stores the location_id from location(id). I do understand that I need to have a reference table in the middle of each relationship, but am unable to find a definable relationship within the scope of CakePHP. HABTM seems to be the closest option, but may be I need something different. Thanks Loke On Jan 8, 2:28 pm, John Andersen j.andersen...@gmail.com wrote: What are the requirements for Model3? Must there be a relationship to Model2 if there is a relationship to Model1 and vice versa? Enjoy, John On Jan 8, 9:05 pm, loke developer.l...@gmail.com wrote: I have a relational requirement where more than one models are related to another model. I want to define the relations with an index table for each relationship between the two models. Model1 - Model1_Model3_index - Model3 Model2 - Model2_Model3_index - Model3 I could see HABTM to be a solution, but the relationship between Model1- Model3 and Model2-Model3 has to be a 1 -to- n relationship. Thanks 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: one to many Model relations
Or may be, I do not even need a reference table in the middle, because there is a singular relationship between each pair of models. So storing the id of the location in each table should be enough to refer to the correct location. It is a many-to-one relationship. Thanks Loke On Jan 9, 6:27 pm, loke developer.l...@gmail.com wrote: Well, the situation is like this: Locations(id, location_info) is an independent table to store all relevant locations. Jobs (id, name, location_id) is a table that has exactly one location for each job, and stores the location_id from location(id). Shops(id, name, location_id) is another table that has exactly one location for each shop, and stores the location_id from location(id). I do understand that I need to have a reference table in the middle of each relationship, but am unable to find a definable relationship within the scope of CakePHP. HABTM seems to be the closest option, but may be I need something different. Thanks Loke On Jan 8, 2:28 pm, John Andersen j.andersen...@gmail.com wrote: What are the requirements for Model3? Must there be a relationship to Model2 if there is a relationship to Model1 and vice versa? Enjoy, John On Jan 8, 9:05 pm, loke developer.l...@gmail.com wrote: I have a relational requirement where more than one models are related to another model. I want to define the relations with an index table for each relationship between the two models. Model1 - Model1_Model3_index - Model3 Model2 - Model2_Model3_index - Model3 I could see HABTM to be a solution, but the relationship between Model1- Model3 and Model2-Model3 has to be a 1 -to- n relationship. Thanks 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: one to many Model relations
Yes, exactly :) Using CakePHP models, the result is: Location hasMany Job Location hasMany Shop But are each Job independent of Shop? Enjoy, John On Jan 10, 1:31 am, loke developer.l...@gmail.com wrote: Or may be, I do not even need a reference table in the middle, because there is a singular relationship between each pair of models. So storing the id of the location in each table should be enough to refer to the correct location. It is a many-to-one relationship. Thanks Loke On Jan 9, 6:27 pm, loke developer.l...@gmail.com wrote: Well, the situation is like this: Locations(id, location_info) is an independent table to store all relevant locations. Jobs (id, name, location_id) is a table that has exactly one location for each job, and stores the location_id from location(id). Shops(id, name, location_id) is another table that has exactly one location for each shop, and stores the location_id from location(id). I do understand that I need to have a reference table in the middle of each relationship, but am unable to find a definable relationship within the scope of CakePHP. HABTM seems to be the closest option, but may be I need something different. Thanks Loke On Jan 8, 2:28 pm, John Andersen j.andersen...@gmail.com wrote: What are the requirements for Model3? Must there be a relationship to Model2 if there is a relationship to Model1 and vice versa? Enjoy, John On Jan 8, 9:05 pm, loke developer.l...@gmail.com wrote: I have a relational requirement where more than one models are related to another model. I want to define the relations with an index table for each relationship between the two models. Model1 - Model1_Model3_index - Model3 Model2 - Model2_Model3_index - Model3 I could see HABTM to be a solution, but the relationship between Model1- Model3 and Model2-Model3 has to be a 1 -to- n relationship. Thanks 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
one to many Model relations
I have a relational requirement where more than one models are related to another model. I want to define the relations with an index table for each relationship between the two models. Model1 - Model1_Model3_index - Model3 Model2 - Model2_Model3_index - Model3 I could see HABTM to be a solution, but the relationship between Model1- Model3 and Model2-Model3 has to be a 1 -to- n relationship. Thanks 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: one to many Model relations
What are the requirements for Model3? Must there be a relationship to Model2 if there is a relationship to Model1 and vice versa? Enjoy, John On Jan 8, 9:05 pm, loke developer.l...@gmail.com wrote: I have a relational requirement where more than one models are related to another model. I want to define the relations with an index table for each relationship between the two models. Model1 - Model1_Model3_index - Model3 Model2 - Model2_Model3_index - Model3 I could see HABTM to be a solution, but the relationship between Model1- Model3 and Model2-Model3 has to be a 1 -to- n relationship. Thanks 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
emulate hasMany relationship as Master/Detail relation or one to many
I am using hasMany Relationship with cakephp. I have relationship like Tender=hasMany=TenderDocuments with this kind of relationship. I am at http://localhost/cakephp/index.php/tenders/add; Now i click New Tender Document and goto http://localhost/projects/cakephp/index.php/tender_documents/add What I want is that there should be either no display of tender combo as i want it to be directly associated with the tender from where the Tender that I am currently adding. How to achive the same? This is a kind of one-to-many relationship Thanks in advance CSJakharia My Code is like this class Tender extends AppModel { var $name='Tender'; var $hasMany=array('TenderDocument'=array( 'className'='TenderDocument', //'conditions' = array('Tender.id = TenderDocument.tender_id'), 'order'=null, 'foreignKey'='tender_id', 'exclusive'=false, 'dependent'=true )); } ?php class TenderDocument extends AppModel { var $name='TenderDocument'; var $belongsTo=array('Tender'=array( 'className'='Tender', 'conditions'=null, 'order'=null, 'foreignKey'='tender_id' )); } ? 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: emulate hasMany relationship as Master/Detail relation or one to many
Suggested solution to your master/detail presentation: 1) When chosing (or after having added) the Tender store the tender id in the session (possibly the model already does this, haven't checked). 2) When activating New tender document use an element in your tender_documents add view to retrieve and present the current Tender information (summary). 3) When saving the new tender document, add the tender id from the session to the data (or from the tender model, should the model already have this information). Enjoy, John On Dec 6, 9:47 am, csplrj csp...@yahoo.co.in wrote: I am using hasMany Relationship with cakephp. I have relationship like Tender=hasMany=TenderDocuments with this kind of relationship. I am at http://localhost/cakephp/index.php/tenders/add; Now i click New Tender Document and gotohttp://localhost/projects/cakephp/index.php/tender_documents/add What I want is that there should be either no display of tender combo as i want it to be directly associated with the tender from where the Tender that I am currently adding. How to achive the same? This is a kind of one-to-many relationship Thanks in advance CSJakharia My Code is like this class Tender extends AppModel { var $name='Tender'; var $hasMany=array('TenderDocument'=array( 'className'='TenderDocument', //'conditions' = array('Tender.id = TenderDocument.tender_id'), 'order'=null, 'foreignKey'='tender_id', 'exclusive'=false, 'dependent'=true )); } ?php class TenderDocument extends AppModel { var $name='TenderDocument'; var $belongsTo=array('Tender'=array( 'className'='Tender', 'conditions'=null, 'order'=null, 'foreignKey'='tender_id' )); } ? 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: One to Many
Hmm... Maybe nobody can't understand me, but i show You: My table 'tags' fields: id, name, foreign_key, model, created, modified (table simlar to 'i18n'), and i want adding tags with some content (add event, add post, add article, etc.) - this is simple, but I want automatically fill in the fields: 'foreign_key' and 'model'. My question is: How do I do? Each idea will be helpful! Thanks a lot! Bye On Sep 21, 2:57 pm, kicaj ki...@kdev.pl wrote: Hi, I looking-for solutions like this:http://mrphp.com.au/code/code-category/cakephp/cakephp-1-2/attach-com... But I would like automatic set field 'class' and 'foreign_id' (or in beforeSave()) My vision is: One model Comments for many other Models (Post, Event, Article, etc.) --~--~-~--~~~---~--~~ 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: One to Many
Use TagBehavior. It does exactly that. http://bakery.cakephp.org/articles/view/simple-tagging-behavior On Tue, Sep 22, 2009 at 4:28 PM, kicaj ki...@kdev.pl wrote: Hmm... Maybe nobody can't understand me, but i show You: My table 'tags' fields: id, name, foreign_key, model, created, modified (table simlar to 'i18n'), and i want adding tags with some content (add event, add post, add article, etc.) - this is simple, but I want automatically fill in the fields: 'foreign_key' and 'model'. My question is: How do I do? Each idea will be helpful! Thanks a lot! Bye On Sep 21, 2:57 pm, kicaj ki...@kdev.pl wrote: Hi, I looking-for solutions like this:http://mrphp.com.au/code/code-category/cakephp/cakephp-1-2/attach-com... But I would like automatic set field 'class' and 'foreign_id' (or in beforeSave()) My vision is: One model Comments for many other Models (Post, Event, Article, etc.) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
One to Many
Hi, I looking-for solutions like this: http://mrphp.com.au/code/code-category/cakephp/cakephp-1-2/attach-comments-any-model-cakephp But I would like automatic set field 'class' and 'foreign_id' (or in beforeSave()) My vision is: One model Comments for many other Models (Post, Event, Article, etc.) --~--~-~--~~~---~--~~ 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: Storing arrays in the database (one field many values)
Do I need to set foreign keys (author_id, book_id) to the tables (books, authors)? How do I make my views have multiple selection fields and how do I store them (because they're in an array)? On Aug 7, 10:15 am, Robert P shiftyrobs...@gmail.com wrote: Well, if Books can have more than one Author in your system then it's: Authors hasAndBelongsToMany Books Books hasAndBelongsToMany Authors But if each book can only have one Author then it would be: Authors hasMany Books Book belongsTo Author with the foreign keys set up as required. Please read the Cookbook -http://book.cakephp.org/view/78/Associations-Linking-Models-Together On Aug 7, 8:29 am,Rawnaasumaw...@gmail.com wrote: On Aug 7, 2:48 am, Vijay Kumbhar k.vidn...@gmail.com wrote: Better way please create new table that will take the book_id the auther_id so that you can associate the models. What Model relationship should I do to create that? Could you please give an example? --~--~-~--~~~---~--~~ 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: Storing arrays in the database (one field many values)
It is always a bad idea to try and squeeze lists into a single field. It will inevitably lead to you pulling your hair out in the future. Anyone who is tempted to store comma separated lists in a field because its 'easier' should spend a few minutes reading about database normalization. http://dev.mysql.com/tech-resources/articles/intro-to-normalization.html is a great place to start. Following a few simple 'rules' when developing your tables will save you the headache of trying to write overly complex SELECT queries in the future. On Aug 6, 2:19 am, Rawna asumaw...@gmail.com wrote: How do I store an array into the database? Here's the view: echo $form-input('name'); echo $form-input('bio'); echo $form-input('book_id', array('multiple' = true)); What if I got multiple books? How do I store them in the database? Whenever I tried saving the entry I get these errors: Notice (8): Array to string conversion Warning (512): SQL Error: 1054: Unknown column 'Array' in 'field list' Query: INSERT INTO `authors` (`name`, `bio`, `book_id`) VALUES ('Chuck Palahniuk', 'Great writer', Array) I created the BookController using bake BTW. Thanks in advance! --~--~-~--~~~---~--~~ 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: Storing arrays in the database (one field many values)
I use serialization when: 1. The array is a preference hash (used for settings in plugins). This is a kind of caching to the db if you will. 2. The array is a very complex or in some other way messy structure that is only stored for logging purposes. One example is the rats-nest called MM7 (SOAP xml-data for MMS services) and similar data that would make up 70% of your database schema if stored in tables and fields. But I agree that is has major drawbacks if and when you find the need to actually search through data stored this way. /Martin On Aug 10, 5:25 pm, CobaltShark cobaltsharksoftw...@gmail.com wrote: It is always a bad idea to try and squeeze lists into a single field. It will inevitably lead to you pulling your hair out in the future. Anyone who is tempted to store comma separated lists in a field because its 'easier' should spend a few minutes reading about database normalization.http://dev.mysql.com/tech-resources/articles/intro-to-normalization.html is a great place to start. Following a few simple 'rules' when developing your tables will save you the headache of trying to write overly complex SELECT queries in the future. On Aug 6, 2:19 am, Rawna asumaw...@gmail.com wrote: How do I store an array into the database? Here's the view: echo $form-input('name'); echo $form-input('bio'); echo $form-input('book_id', array('multiple' = true)); What if I got multiple books? How do I store them in the database? Whenever I tried saving the entry I get these errors: Notice (8): Array to string conversion Warning (512): SQL Error: 1054: Unknown column 'Array' in 'field list' Query: INSERT INTO `authors` (`name`, `bio`, `book_id`) VALUES ('Chuck Palahniuk', 'Great writer', Array) I created the BookController using bake BTW. Thanks in advance! --~--~-~--~~~---~--~~ 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: Storing arrays in the database (one field many values)
i wouldn't say that vijay was incorrect - he ment the same thing, just didn't express it as clear as you, miles :) either way it is way cleaner to normalize the database - this way you have more control over the multiple choices and if you delete one choice, you can make sure it is not related to any record (with your arrays as serialized string this is not a nice thing to do) On 7 Aug., 04:15, Robert P shiftyrobs...@gmail.com wrote: Well, if Books can have more than one Author in your system then it's: Authors hasAndBelongsToMany Books Books hasAndBelongsToMany Authors But if each book can only have one Author then it would be: Authors hasMany Books Book belongsTo Author with the foreign keys set up as required. Please read the Cookbook -http://book.cakephp.org/view/78/Associations-Linking-Models-Together On Aug 7, 8:29 am, Rawna asumaw...@gmail.com wrote: On Aug 7, 2:48 am, Vijay Kumbhar k.vidn...@gmail.com wrote: Better way please create new table that will take the book_id the auther_id so that you can associate the models. What Model relationship should I do to create that? Could you please give an example? --~--~-~--~~~---~--~~ 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: Storing arrays in the database (one field many values)
well ok serializing/unseriazing is still different than implode/explode both are not very handy though implode could be better if you want to search your in your pseudo array with LIKE %{...}% serializing if you dont want to do anything expect then saving/reading hasMany or even HABTM as Robert stated would be the best choice in most cases especially as cake has beautiful automation for it anyway On 7 Aug., 16:46, euromark (munich) dereurom...@googlemail.com wrote: i wouldn't say that vijay was incorrect - he ment the same thing, just didn't express it as clear as you, miles :) either way it is way cleaner to normalize the database - this way you have more control over the multiple choices and if you delete one choice, you can make sure it is not related to any record (with your arrays as serialized string this is not a nice thing to do) On 7 Aug., 04:15, Robert P shiftyrobs...@gmail.com wrote: Well, if Books can have more than one Author in your system then it's: Authors hasAndBelongsToMany Books Books hasAndBelongsToMany Authors But if each book can only have one Author then it would be: Authors hasMany Books Book belongsTo Author with the foreign keys set up as required. Please read the Cookbook -http://book.cakephp.org/view/78/Associations-Linking-Models-Together On Aug 7, 8:29 am, Rawna asumaw...@gmail.com wrote: On Aug 7, 2:48 am, Vijay Kumbhar k.vidn...@gmail.com wrote: Better way please create new table that will take the book_id the auther_id so that you can associate the models. What Model relationship should I do to create that? Could you please give an example? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Storing arrays in the database (one field many values)
How do I store an array into the database? Here's the view: echo $form-input('name'); echo $form-input('bio'); echo $form-input('book_id', array('multiple' = true)); What if I got multiple books? How do I store them in the database? Whenever I tried saving the entry I get these errors: Notice (8): Array to string conversion Warning (512): SQL Error: 1054: Unknown column 'Array' in 'field list' Query: INSERT INTO `authors` (`name`, `bio`, `book_id`) VALUES ('Chuck Palahniuk', 'Great writer', Array) I created the BookController using bake BTW. Thanks in advance! --~--~-~--~~~---~--~~ 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: Storing arrays in the database (one field many values)
You can not store array(); in the database.You have to separate the array elements using implode function then you can add it to the data base. Better way please create new table that will take the book_id the auther_id so that you can associate the models. On Thu, Aug 6, 2009 at 2:49 PM, Rawna asumaw...@gmail.com wrote: How do I store an array into the database? Here's the view: echo $form-input('name'); echo $form-input('bio'); echo $form-input('book_id', array('multiple' = true)); What if I got multiple books? How do I store them in the database? Whenever I tried saving the entry I get these errors: Notice (8): Array to string conversion Warning (512): SQL Error: 1054: Unknown column 'Array' in 'field list' Query: INSERT INTO `authors` (`name`, `bio`, `book_id`) VALUES ('Chuck Palahniuk', 'Great writer', Array) I created the BookController using bake BTW. Thanks in advance! -- Thanks Regards, Vijayk. Co-founder (www.weboniselab.com) You Bring the Dreams, We'll Bring the Means --~--~-~--~~~---~--~~ 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: Storing arrays in the database (one field many values)
Vijay is slightly incorrect. You can serialize() an array and save it as a text string in the database, and unserialize() when retrieving the data. --~--~-~--~~~---~--~~ 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: Storing arrays in the database (one field many values)
On Aug 7, 2:48 am, Vijay Kumbhar k.vidn...@gmail.com wrote: Better way please create new table that will take the book_id the auther_id so that you can associate the models. What Model relationship should I do to create that? Could you please give an example? --~--~-~--~~~---~--~~ 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: Storing arrays in the database (one field many values)
Well, if Books can have more than one Author in your system then it's: Authors hasAndBelongsToMany Books Books hasAndBelongsToMany Authors But if each book can only have one Author then it would be: Authors hasMany Books Book belongsTo Author with the foreign keys set up as required. Please read the Cookbook - http://book.cakephp.org/view/78/Associations-Linking-Models-Together On Aug 7, 8:29 am, Rawna asumaw...@gmail.com wrote: On Aug 7, 2:48 am, Vijay Kumbhar k.vidn...@gmail.com wrote: Better way please create new table that will take the book_id the auther_id so that you can associate the models. What Model relationship should I do to create that? Could you please give an example? --~--~-~--~~~---~--~~ 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: SaveAll + one-to-many
Hi Joshua, If you have a $data array containing data for a record in A and 0 or more records in B, you can use saveAll. So, if your $data is something like: array( [A] = array( [id] = 12, [otherdata] = 'some string' ), [B] = array( [0] = array(..), [1] = array(..) ) ); you can call model A in your a-controller: A-saveAll($data,array('atomic' = true, 'validate' = 'first')); This will save all the data in the A-record and associated B-records. But take care: - This will only work if you have set up the relationship. So in A there must be something like: var $hasMany = array('B' = array('dependent' = true)) and in B: var $belongsTo = 'A' Check the meaning of these options here: http://book.cakephp.org/view/78/Associations-Linking-Models-Together - The 'atomic' option only works if you can use transactions, like in mysql InnoDB (not the default myIsam) tables. - Tip: put this before the line where you want to use saveAll, to see if the $data is ok: pr($data); exit(); This will save A + B. The only thing it will not do is remove the records in B that no longer belong to A. This is something I will post an item about, right now. Jelmer --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
How to use SaveAll to save one-to-many relationship datas?
If todos table has one-to-many relationship with tasks table, what the data format should be if I want save all of them at once? //like SaveAll($data) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
SaveAll + one-to-many
I have no idea on how to save model A that has a one-to-many relationship with module B. Example: --- table A id name -- table B id a_id name -- How to do this if I want to save A with many B records in model A function. I really google a lot of resource, but I didn't find the answer there. http://www.packtpub.com/article/working-with-simple-associations-using-cakephp http://blog.matsimitsu.nl/code/166/saveall-with-cakephp-part2 I will appreciate for your answer. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
beforeFind called one too many times with hasMany?
Hey All, I have a model, hasMany associated-model, and I'm finding when using the beforeFind callback inside associated-model, it is called more times than I'm expecting. For each associated record found it is called (with results like [0][associated-model]), and then for all the records together it is called again (with results like [0] [associated-model][n]). My original issue was I was using beforeFind to do something toggling of values, which where being re-toggled in the final beforeFind call. I've worked around the problem, but I was hoping someone could shed some light on why this happens at all. From what I can figure out so far, the first set of calls for the individual results, and the last call for all the results together, are triggered from 2 different points in read() in dbo_source.php. It looks like to me __filterResults() is being called via queryAssociation() for each record at line 661, and then again for all of them when the loop ends, at line 666 (appropriately so for something I though was an evil bug). This also looks on purpose to me, but I am wondering why. Using 1.2.0.7296 RC2 Thanks! --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: many-to-many and one-to-many associations
Hi, many thanks for the adivce, i agree with your opinion, but like you say none of the solutions are the better way for now i used another solution (new field on posts table for counting the comments) it breaks some modelling rules but for now solves the problem easly regards Paulo On Aug 19, 11:40 pm, MonkeyGirl [EMAIL PROTECTED] wrote: Hi. I don't necessarily know what I'm talking about, but no one else has spoken up, so here goes... The way I would get the aggregate would not be to change the finderQuery in the hasAndBelongsToMany definition. It didn't even occur to me that you could do that. Then again, maybe I'm just being naive. Either of these ways should work: The wasteful way: just do a findAll on the tag and recurse it as necessary. It will list all the posts that use it, and all the comments that each post has. Use PHP's count() function rather than SQL aggregates to count how many comments are in each post. As I say, this is very much needlessly wasteful, although you can curb the waste somewhat by unbinding the unneeded models temporarily before the findAll. The custom way: make a new method in one of the models that takes a tag ID and calls $this-query with the SQL you've pasted above, and a WHERE clause that makes use of the tag ID. This is probably the best way of doing it (it's certainly the best way I know of myself), but I'll bet someone else can suggest a better way. But as I say, I'm by no means an expert, so take my advice with a pinch of salt. Hope that helps, Zoe. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: many-to-many and one-to-many associations
Hi. I don't necessarily know what I'm talking about, but no one else has spoken up, so here goes... The way I would get the aggregate would not be to change the finderQuery in the hasAndBelongsToMany definition. It didn't even occur to me that you could do that. Then again, maybe I'm just being naive. Either of these ways should work: The wasteful way: just do a findAll on the tag and recurse it as necessary. It will list all the posts that use it, and all the comments that each post has. Use PHP's count() function rather than SQL aggregates to count how many comments are in each post. As I say, this is very much needlessly wasteful, although you can curb the waste somewhat by unbinding the unneeded models temporarily before the findAll. The custom way: make a new method in one of the models that takes a tag ID and calls $this-query with the SQL you've pasted above, and a WHERE clause that makes use of the tag ID. This is probably the best way of doing it (it's certainly the best way I know of myself), but I'll bet someone else can suggest a better way. But as I say, I'm by no means an expert, so take my advice with a pinch of salt. Hope that helps, Zoe. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
many-to-many and one-to-many associations
Hi, i'm trying to solve a problem using the cakephp modeling. I have 3 tables: posts, comments and tags, where - one post have 0 or many comments - one post have one or many tags my physical tables structure is: posts (*id, name, text, date_created) tags(*id,name) comments(*id,post_id, text, username) posts_tags(*post_id,*tag_id) when i list all posts by a specific tag (http://localhost/posts/tag/ cinema) i want to a have a list of posts with all Posts fields and the sum of comments per post, for that in the tags model i put the following association: var $hasAndBelongsToMany = array('Posts' = array( 'className' = 'Posts', 'joinTable' = 'posts_tags', 'foreignKey' = 'tag_id', 'associationForeignKey' = 'post_id', 'conditions' = '', 'order' = '', 'limit' = '', 'uniq' = '', 'finderQuery'= 'SELECT `Posts`.`id`,`Posts`.`name`, `Posts`.`text`,`Posts`.`date_created`, count(`Comments`.`id`) FROM `posts` AS `Posts` LEFT JOIN `comments` as `Comments` ON (`Comments`.`post_id`=`Posts`.`id`) JOIN `tags` as `Tags` ON (`Tags`.`id`={$__cakeID__$}) JOIN `posts_tags` as `posts_tags` ON (`posts_tags`.`post_id`=`Posts`.`id` AND `posts_tags`.`tag_id`=`Tags`.`id`) GROUP BY `Posts`.`id` ORDER BY `Posts`.`date_created` DESC', 'deleteQuery'= '', 'insertQuery'= '' ) ); the query used in the finderQuery returns the pretended fields in mysql and cake debug, but the returned array is empty!: $this-set('posts', $this-Weblog-Tags-find('all', array('conditions' = array('Tags.name' = $this-Weblog-tag_id; posts will return: Array ( [0] = Array ( [Tags] = Array ( [id] = 5 [name] = apple [description] = ) [Posts] = Array ( ) ) ) i can solve the problem using the query method but i think i'm doing something wrong, so waiting for any advice. Regards Paulo Gomes --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: One to many forms with ajax
Did you find the solution? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: One app, many roles and priviledges. How?
I repeat what I put in the other post, have you heard of ACL? With a correct ACL tree, you can limit access depending on the role, just like the thing that you wanna do. Of course, if for example you have differente edits for different roles, then there is no ACL that can help you. But with the scenario that you gave, ACL is enough. Cheers, mbavio On Jun 2, 4:08 pm, James K [EMAIL PROTECTED] wrote: Unless the different roles have access to totally different functionality, I don't see why you'd want to do this. It'd be much easier to have the form(s) customize themselves based on what the user's role is - or better yet, implement an ACL tree to cover all the different functionalities available to each role. On Jun 2, 10:20 am, Jaime [EMAIL PROTECTED] wrote: Hello everybody, This topic is quite similar tohttp://groups.google.com/group/cake-php/browse_thread/thread/35900a65... which remains still unresolved. It's just about a common scenario while building a corporate Intranet. There is a fine DB and many models with their relationships... There are also lots of users, and each users belongs to a role. So the MANAGERS can add/edit/delete everything, but (let's say) WORKERS can only read/write to some things, and last, CUSTOMERS can only read a part of the data. Cake's admin routes are nice, but are designed for a simpler scenario (Users vs. Admins), so won't help here. The only thing I can imagin is quite LAME: class contract_controller extends AppController { function _edit_contract_by_laywer($id) { ...my_lame_private_method... } function _edit_contract_by_broker($id) { ...my_lame_private_method... } function _edit_contract_by_manager($id) { ...my_lame_private_method... } function edit($id) { if ($role == 'LAYWER') { $this-_edit_contract_by_laywer($id); $this-render('edit_contract_by_lawyer'); } elseif ($role == 'BROKWER') { $this-_edit_contract_by_broker($id); $this-render('edit_contract_by_broker'); } elseif ($role == 'MANAGER') { $this-_edit_contract_by_manager($id); $this-render('edit_contract_by_manager'); } } } --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
One app, many roles and priviledges. How?
Hello everybody, This topic is quite similar to http://groups.google.com/group/cake-php/browse_thread/thread/35900a65ab04ab05/92b6e71a451c35d0?lnk=gstq=roles which remains still unresolved. It's just about a common scenario while building a corporate Intranet. There is a fine DB and many models with their relationships... There are also lots of users, and each users belongs to a role. So the MANAGERS can add/edit/delete everything, but (let's say) WORKERS can only read/write to some things, and last, CUSTOMERS can only read a part of the data. Cake's admin routes are nice, but are designed for a simpler scenario (Users vs. Admins), so won't help here. The only thing I can imagin is quite LAME: class contract_controller extends AppController { function _edit_contract_by_laywer($id) { ...my_lame_private_method... } function _edit_contract_by_broker($id) { ...my_lame_private_method... } function _edit_contract_by_manager($id) { ...my_lame_private_method... } function edit($id) { if ($role == 'LAYWER') { $this-_edit_contract_by_laywer($id); $this-render('edit_contract_by_lawyer'); } elseif ($role == 'BROKWER') { $this-_edit_contract_by_broker($id); $this-render('edit_contract_by_broker'); } elseif ($role == 'MANAGER') { $this-_edit_contract_by_manager($id); $this-render('edit_contract_by_manager'); } } } --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: One app, many roles and priviledges. How?
You might find this article interesting: http://bakery.cakephp.org/articles/view/using-cake_admin-for-multiple-user-types --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: One app, many roles and priviledges. How?
On 2 jun, 14:20, Jaime [EMAIL PROTECTED] wrote: Cake's admin routes are nice, but are designed for a simpler scenario (Users vs. Admins), so won't help here. Since CakePHP 1.2 there is the possibility to define custom prefix routing, so it can be possible to do something like: Router::connect('/brokers/contract/edit', array('prefix' = 'brokers')); Router::connect('/laywers/contract/edit', array('prefix' = 'laywers')); Router::connect('/managers/contract/edit', array('prefix' = 'managers')); And then define the contract_controller like: class contract_controller extends AppController { function brokers_edit($id) { ...my_private_method... } function managers_edit($id) { ...my_private_method... } function lawyers_edit($id) { ...my_private_method... } } Which looks to me better than the horrible if/elseif/elseif structure suggested before. Any guru out there willing to give a piece of advice on how to improve this? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: One app, many roles and priviledges. How?
Since CakePHP 1.2 there is the possibility to define custom prefix routing, so it can be possible to do something like: Router::connect('/brokers/contract/edit', array('prefix' = 'brokers')); Router::connect('/laywers/contract/edit', array('prefix' = 'laywers')); Router::connect('/managers/contract/edit', array('prefix' = 'managers')); Cool! How did I miss that? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: One app, many roles and priviledges. How?
Unless the different roles have access to totally different functionality, I don't see why you'd want to do this. It'd be much easier to have the form(s) customize themselves based on what the user's role is - or better yet, implement an ACL tree to cover all the different functionalities available to each role. On Jun 2, 10:20 am, Jaime [EMAIL PROTECTED] wrote: Hello everybody, This topic is quite similar tohttp://groups.google.com/group/cake-php/browse_thread/thread/35900a65... which remains still unresolved. It's just about a common scenario while building a corporate Intranet. There is a fine DB and many models with their relationships... There are also lots of users, and each users belongs to a role. So the MANAGERS can add/edit/delete everything, but (let's say) WORKERS can only read/write to some things, and last, CUSTOMERS can only read a part of the data. Cake's admin routes are nice, but are designed for a simpler scenario (Users vs. Admins), so won't help here. The only thing I can imagin is quite LAME: class contract_controller extends AppController { function _edit_contract_by_laywer($id) { ...my_lame_private_method... } function _edit_contract_by_broker($id) { ...my_lame_private_method... } function _edit_contract_by_manager($id) { ...my_lame_private_method... } function edit($id) { if ($role == 'LAYWER') { $this-_edit_contract_by_laywer($id); $this-render('edit_contract_by_lawyer'); } elseif ($role == 'BROKWER') { $this-_edit_contract_by_broker($id); $this-render('edit_contract_by_broker'); } elseif ($role == 'MANAGER') { $this-_edit_contract_by_manager($id); $this-render('edit_contract_by_manager'); } } } --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Adding data in a One-To-Many Relationship
That's right. It works now. Thank you :) On May 1, 2008, at 8:25 AM, validkeys wrote: if you hadn't figured this one out. If you are trying to access your models model from your parts model to create a drop down of models in a parts view, use the following: latest 1.2: $this-Part-Model-find('list'); earlier: $this-Part-Model-generateList(); does that help? On Apr 30, 7:20 am, Reza Muhammad [EMAIL PROTECTED] wrote: Forget my ignorance, I forgot to use var $belongsTo. :) On Apr 30, 2008, at 3:22 PM, Reza Muhammad wrote: Hi Guys, I just started using CakePHP 1.2, and I have a question concerning a One to Many relationships. I have two models, 'Model' and 'Part'. One model can have many parts. I don't have a problem creating Model controller, but when I want to add new parts, I want to have a list of the Models, and let the user choose using a drop down menu (select/select) Can anyone tell me how to use this? Thank you very much. -Reza --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Adding data in a One-To-Many Relationship
Hi Guys, I just started using CakePHP 1.2, and I have a question concerning a One to Many relationships. I have two models, 'Model' and 'Part'. One model can have many parts. I don't have a problem creating Model controller, but when I want to add new parts, I want to have a list of the Models, and let the user choose using a drop down menu (select/select) Can anyone tell me how to use this? Thank you very much. -Reza --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Adding data in a One-To-Many Relationship
Forget my ignorance, I forgot to use var $belongsTo. :) On Apr 30, 2008, at 3:22 PM, Reza Muhammad wrote: Hi Guys, I just started using CakePHP 1.2, and I have a question concerning a One to Many relationships. I have two models, 'Model' and 'Part'. One model can have many parts. I don't have a problem creating Model controller, but when I want to add new parts, I want to have a list of the Models, and let the user choose using a drop down menu (select/select) Can anyone tell me how to use this? Thank you very much. -Reza --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Adding data in a One-To-Many Relationship
if you hadn't figured this one out. If you are trying to access your models model from your parts model to create a drop down of models in a parts view, use the following: latest 1.2: $this-Part-Model-find('list'); earlier: $this-Part-Model-generateList(); does that help? On Apr 30, 7:20 am, Reza Muhammad [EMAIL PROTECTED] wrote: Forget my ignorance, I forgot to use var $belongsTo. :) On Apr 30, 2008, at 3:22 PM, Reza Muhammad wrote: Hi Guys, I just started using CakePHP 1.2, and I have a question concerning a One to Many relationships. I have two models, 'Model' and 'Part'. One model can have many parts. I don't have a problem creating Model controller, but when I want to add new parts, I want to have a list of the Models, and let the user choose using a drop down menu (select/select) Can anyone tell me how to use this? Thank you very much. -Reza --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
One-to-many and one-to-one relationships between the same two tables...
I have a situation that I'm not sure how to build the cake model relationships for. I have two tables, Companies and Contacts. A Company can have many contacts but it also has one primary contact. I figured I would set up hasMany and belongsTo entries for the Company and Contact models. But how do I set up the secondary link? I have the Contacts table set up with a company_id field to relate it to the company table. I think I should create a field in the Company table called primary_contact_id but I'm not sure how to set up the model relationships. Thanks in advance! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: One-to-many and one-to-one relationships between the same two tables...
On Feb 18, 5:26 am, dasn [EMAIL PROTECTED] wrote: I have a situation that I'm not sure how to build the cake model relationships for. I have two tables, Companies and Contacts. A Company can have many contacts but it also has one primary contact. I figured I would set up hasMany and belongsTo entries for the Company and Contact models. But how do I set up the secondary link? I have the Contacts table set up with a company_id field to relate it to the company table. I think I should create a field in the Company table called primary_contact_id but I'm not sure how to set up the model relationships. Thanks in advance! http://groups.google.com/group/cake-php/browse_frm/thread/9fe64a3f64027807/60ce8ba56eb2429b (don't only read my opinion in that thread) hth, AD --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
one to many and many to one ???.
aHi I have a people file and an events file zI wan to show the one person and show all events with add , delete view activity. code= ?php class Person extends AppModel { var $name = Person; var $hasMany = array('events' = array('className' = 'Event', // 'conditions'= 'Comment.moderated = 1', // 'order' = 'Comment.created id', // 'limit' = '100', 'foreignKey'= 'person_id', // 'dependent' = true, // 'exclusive' = false, 'finderQuery' = '' ) ); } ? -- ?php class PeopleController extends AppController { var $name = People; var $scaffold; } ? ?php class EventsController extends AppController { var $name = Events; var $scaffold; } ? -- When I run the events I get the events but not the person related to the events. How does scaffolding work Jim --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: one to many and many to one ???.
It's not a scaffolding problem, it's a model relation problem (you did not show the Event model). You can't get the person by querying the Events if there is no relation from events to person. Either you make the events belongsTo person or you query your Events from the Person model. On Sep 4, 7:38 pm, SIXS [EMAIL PROTECTED] wrote: aHi I have a people file and an events file zI wan to show the one person and show all events with add , delete view activity. code= ?php class Person extends AppModel { var $name = Person; var $hasMany = array('events' = array('className' = 'Event', // 'conditions'= 'Comment.moderated = 1', // 'order' = 'Comment.created id', // 'limit' = '100', 'foreignKey'= 'person_id', // 'dependent' = true, // 'exclusive' = false, 'finderQuery' = '' ) ); } ? -- ?php class PeopleController extends AppController { var $name = People; var $scaffold;} ? ?php class EventsController extends AppController { var $name = Events; var $scaffold;} ? -- When I run the events I get the events but not the person related to the events. How does scaffolding work Jim --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
One to many forms with ajax
It's always boggled me why there are lots of many to many relationship examples but hardly any one to many examples. My major stumbling block here is how to set up the form and controller to save the detail lines when 'Save' is clicked and how to manage the detail table when Add/Del are clicked. Is there an example/sample/tutorial someone can point me to, of one to many forms with an editable grid out there, i.e. something like an invoice/order form such as below the ||'s indicate editable fields and 's buttons/links. | Customer Choosing combo/Auto complete |v| Address1 Address2 Address3 Item Code Qty Unit Price Total | |||| || | Del | |||| || | Del | |||| || | Del Add -- SubTotal Tax Total Save Any other ideas/ you're an idiot's etc are welcome so long as they are helpful. Regards Jeremy --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: One to many forms with ajax
In case it makes a difference I'm using CakePHP 1.2 Jeremy David Pointer wrote: It's always boggled me why there are lots of many to many relationship examples but hardly any one to many examples. My major stumbling block here is how to set up the form and controller to save the detail lines when 'Save' is clicked and how to manage the detail table when Add/Del are clicked. Is there an example/sample/tutorial someone can point me to, of one to many forms with an editable grid out there, i.e. something like an invoice/order form such as below the ||'s indicate editable fields and 's buttons/links. | Customer Choosing combo/Auto complete |v| Address1 Address2 Address3 Item Code Qty Unit Price Total | |||| || | Del | |||| || | Del | |||| || | Del Add -- SubTotal Tax Total Save Any other ideas/ you're an idiot's etc are welcome so long as they are helpful. Regards Jeremy --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
One to many relation
My experience with CakePHP has only begun but after creating some small examples with great help of the cake manual I think some areas of interest suffers. A very common issue (problem for starters) is when you have a one-to-many relation in the data source. For an example we can use a list. A list has an id, a name and an owner. Every list has many items (one to many). Therefore I'm creating another table called listrows. The new table will have a id, a listId (to it's parent in the first table) and a name. List: id,name,owner Listrows: id,listId,name The relation is id-listId. How do I use cake for the best implementation of this? If I create a Controller/Model/View called List(s), my ListController will have problems after fetching $this-List-fetchAll(); to get the listId's which belongs to the current list. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: One to many relation
On Oct 9, 2006, at 3:35 PM, Emils wrote: My experience with CakePHP has only begun but after creating some small examples with great help of the cake manual I think some areas of interest suffers. A very common issue (problem for starters) is when you have a one-to-many relation in the data source. For an example we can use a list. A list has an id, a name and an owner. Every list has many items (one to many). Therefore I'm creating another table called listrows. The new table will have a id, a listId (to it's parent in the first table) and a name. List: id,name,owner Listrows: id,listId,name The relation is id-listId. How do I use cake for the best implementation of this? If I create a Controller/Model/View called List(s), my ListController will have problems after fetching $this-List-fetchAll(); to get the listId's which belongs to the current list. Try this: lists: id, name, owner list_rows: id, list_id, name /app/models/list.php: class List extends AppModel { var $name = 'List'; var $hasMany = array('ListRow' = array('className'='ListRow')); } /app/models/list_row.php: class ListRow extends AppModel { var $name = 'ListRow'; var $belongsTo = array('List' = array('className'='List')); } If in a controller, you do $this-List-findAll() or $this-ListRow- findAll(), you should get the right data, associated with its counterpart. -- John --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: deleting multiple records in a one to many association.
This is done for you, if you're using expanded version of the $hasMany member variable. For example, your Group model might contain the following declaration: var $hasMany = array( 'User' = array( 'classname' = 'User', 'conditions' = '', 'order' = '', 'dependent' = true, 'foreignKey' = 'company'), ); You'll see that 'dependent' = true. This means that if the group is deleted, the associated users will be deleted. I'm pretty sure that this is false by default, so if you're using the single-line $hasMany declaration, like this: var $hasMany = array('User'); Then I don't think dependency (called 'cascades') is turned on. For me, single-line declarations don't work (because I've not stuck to the Cake naming conventions, like an idiot!) so this is how I implement all of my hasXXX associations - the long-winded way. HTH James On Oct 5, 6:26 am, maestro777 [EMAIL PROTECTED] wrote: I have a table called Groups which is associated on a one to many with another table called Users. Is there an efficient way of deleting records in the Users table that are link to the one record being deleted in the Groups table? I couldn't find a model-delete('condition') in the API. I think this should be a common situation, and I just wonder how you guys accomplish it. Thanks in advance for your response. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
deleting multiple records in a one to many association.
I have a table called Groups which is associated on a one to many with another table called Users. Is there an efficient way of deleting records in the Users table that are link to the one record being deleted in the Groups table? I couldn't find a model-delete('condition') in the API. I think this should be a common situation, and I just wonder how you guys accomplish it. Thanks in advance for your response. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Updating one or many divs with an ajax call
Hi. I have a question about multiple div updates with ajax. I have an action that processes a form. The page has two divs: 'content_div' and 'form_div'. What i want to do is update only 'form_div' if there are any validation errors (to display them) and update both of them if no validation errors occurred and the save() was successful. Can it be done? Thanks in advance. -- Gonçalo Marrafa [EMAIL PROTECTED] --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: Updating one or many divs with an ajax call
If form_div and content_div are both rendered in the same view, you could do some conditional logic tricks with $ajax-div and $ajax-divEnd. The other thing you could do is have your controller tell the view which part to render based on whether or not the form validates, and update the appropriate element manually in the onComplete callback of the request. You could embed a comment tag in the results that changes based on which contents are returned, and grep the results for the comment contents, and use that to figure out which div to update the results with. Otherwise, what you'd probably have to do is split it into to requests. The first one would be to see if the form validates, and the second one to do the actual update, based on which div should be update. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---