Re: Unable to save related table information
Yes, your data is not CakePHP compatible. The Rental looks find, but it also includes the Rate. The Rate should be at the same level as Rental, and should look like this: [Rate] = Array ( [0] = Array ( [title] = 1 [day] = ... ) [1] = Array ( and so on. You probably have to modify your view or the file that you use to create the view, so that it returns the above structure. Enjoy, John On Jan 15, 1:41 am, koala kid a...@koalawebsolutions.com wrote: Thanks for your input. It looks like below. I think I may have the Model name in the wrong place?? I'm using: echo $form-create('Rental', array('type' = 'file', 'action' = 'edit')); to create the form. Array ( [Rental] = Array ( [id] = 60 [rental_code] = code [location_id] = 37 [rental_agent] = a...@gmail.com [rental_meta_title] = meta title [rental_meta_desc] = meta desc [rental_meta_tags] = meta kewords [rental_short_title] = location title [rental_short_desc] = location desc [rental_title] = prop title [rental_location] = prop location desc [rental_description] = prop desc [rental_features] = feature list [rental_reviews] = review link [rental_availability] = availability link [rental_gallery] = slideshow link [rental_weather] = weather widget [rental_extra_info] = extra info [Rate/s1_title] = 1 [Rate/s1_day] = [Rate/s1_week] = [Rate/s1_month] = [Rate/s2_title] = [Rate/s2_day] = [Rate/s2_week] = [Rate/s2_month] = [Rate/s3_title] = [Rate/s3_day] = [Rate/s3_week] = [Rate/s3_month] = [Rate/s4_title] = [Rate/s4_day] = [Rate/s4_week] = [Rate/s4_month] = [Rate/extra_info] = [rental_short_thumb] = holder.gif ) ) John Andersen-6 wrote: How does your data look like before the saveAll statement? Enjoy, John [snip] 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: Unable to save related table information
Thanks, that fixed it. For some reason I had Rate/ instead of Rate. in my HTML form as the input name, changing that and its now saving. Thanks for the tip. However I've now got another issue! When I submit the form the data is being saved but I get a PHP warning: Warning (2): Illegal offset type in unset [CORE/cake/libs/model/model.php, line 561] Code | Context $params = array( belongsTo = array( Location = array() ) ) $reset = true $models = array( Location = array( className = Location ) ) $assoc = belongsTo $model = array( className = Location ) foreach ($models as $model) { $this-__backAssociation = array_merge($this-__backAssociation, $this-{$assoc}); unset ($this-__backAssociation[$model]); Model::unbindModel() - CORE/cake/libs/model/model.php, line 561 RentalsController::edit() - APP/controllers/rentals_controller.php, line 91 Object::dispatchMethod() - CORE/cake/libs/object.php, line 116 Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 227 Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 194 [main] - APP/webroot/index.php, line 88 It looks like I still haven't got my head around this ORM thing. Have I set up my associations correctly? Thanks for your help. John Andersen-6 wrote: Yes, your data is not CakePHP compatible. The Rental looks find, but it also includes the Rate. The Rate should be at the same level as Rental, and should look like this: [Rate] = Array ( [0] = Array ( [title] = 1 [day] = ... ) [1] = Array ( and so on. You probably have to modify your view or the file that you use to create the view, so that it returns the above structure. Enjoy, John On Jan 15, 1:41 am, koala kid a...@koalawebsolutions.com wrote: Thanks for your input. It looks like below. I think I may have the Model name in the wrong place?? I'm using: echo $form-create('Rental', array('type' = 'file', 'action' = 'edit')); to create the form. Array ( [Rental] = Array ( [id] = 60 [rental_code] = code [location_id] = 37 [rental_agent] = a...@gmail.com [rental_meta_title] = meta title [rental_meta_desc] = meta desc [rental_meta_tags] = meta kewords [rental_short_title] = location title [rental_short_desc] = location desc [rental_title] = prop title [rental_location] = prop location desc [rental_description] = prop desc [rental_features] = feature list [rental_reviews] = review link [rental_availability] = availability link [rental_gallery] = slideshow link [rental_weather] = weather widget [rental_extra_info] = extra info [Rate/s1_title] = 1 [Rate/s1_day] = [Rate/s1_week] = [Rate/s1_month] = [Rate/s2_title] = [Rate/s2_day] = [Rate/s2_week] = [Rate/s2_month] = [Rate/s3_title] = [Rate/s3_day] = [Rate/s3_week] = [Rate/s3_month] = [Rate/s4_title] = [Rate/s4_day] = [Rate/s4_week] = [Rate/s4_month] = [Rate/extra_info] = [rental_short_thumb] = holder.gif ) ) John Andersen-6 wrote: How does your data look like before the saveAll statement? Enjoy, John [snip] 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 -- View this message in context: http://old.nabble.com/Unable-to-save-related-table-information-tp27153345p27182497.html Sent from the CakePHP mailing list archive at Nabble.com. 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: Unable to save related table information
FYI my POST data now looks like this: Array ( [Rental] = Array ( [id] = 1 [rental_code] = SMpenthouse [location_id] = 7 [rental_agent] = m...@gmail.com [rental_meta_title] = [rental_meta_desc] = [rental_meta_tags] = [rental_short_title] = [rental_short_desc] = [rental_title] = Penthouse Apt #45; 2 Blocks from Beach, Weekend Specials [rental_location] = California living at its best! This penthouse condo is located in one of the [rental_description] = From throughout this very spacious and sunny penthouse apartment [rental_features] = Two bedrooms, each with private bathroom [rental_reviews] = http://www.bcvbx.com/guestbook.cfm?pid=122046 [rental_availability] = [rental_gallery] = http://www.hhg.com/ssp_director/images.php?album=14 [rental_weather] = 90401 [rental_extra_info] = One time cleaning fee: $90 [rental_short_thumb] = Array ( [name] = [type] = [tmp_name] = [error] = 4 [size] = 0 ) ) [Rate] = Array ( [s1_title] = s1 Title [s1_day] = [s1_week] = [s1_month] = [s2_title] = [s2_day] = [s2_week] = [s2_month] = [s3_title] = [s3_day] = [s3_week] = [s3_month] = [s4_title] = [s4_day] = [s4_week] = [s4_month] = [extra_info] = ) ) koala kid wrote: Thanks, that fixed it. For some reason I had Rate/ instead of Rate. in my HTML form as the input name, changing that and its now saving. Thanks for the tip. However I've now got another issue! When I submit the form the data is being saved but I get a PHP warning: Warning (2): Illegal offset type in unset [CORE/cake/libs/model/model.php, line 561] Code | Context $params = array( belongsTo = array( Location = array() ) ) $reset= true $models = array( Location = array( className = Location ) ) $assoc= belongsTo $model= array( className = Location ) foreach ($models as $model) { $this-__backAssociation = array_merge($this-__backAssociation, $this-{$assoc}); unset ($this-__backAssociation[$model]); Model::unbindModel() - CORE/cake/libs/model/model.php, line 561 RentalsController::edit() - APP/controllers/rentals_controller.php, line 91 Object::dispatchMethod() - CORE/cake/libs/object.php, line 116 Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 227 Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 194 [main] - APP/webroot/index.php, line 88 It looks like I still haven't got my head around this ORM thing. Have I set up my associations correctly? Thanks for your help. John Andersen-6 wrote: Yes, your data is not CakePHP compatible. The Rental looks find, but it also includes the Rate. The Rate should be at the same level as Rental, and should look like this: [Rate] = Array ( [0] = Array ( [title] = 1 [day] = ... ) [1] = Array ( and so on. You probably have to modify your view or the file that you use to create the view, so that it returns the above structure. Enjoy, John On Jan 15, 1:41 am, koala kid a...@koalawebsolutions.com wrote: Thanks for your input. It looks like below. I think I may have the Model name in the wrong place?? I'm using: echo $form-create('Rental', array('type' = 'file', 'action' = 'edit')); to create the form. Array ( [Rental] = Array ( [id] = 60 [rental_code] = code [location_id] = 37 [rental_agent] = a...@gmail.com [rental_meta_title] = meta title [rental_meta_desc] = meta desc [rental_meta_tags] = meta kewords [rental_short_title] = location title [rental_short_desc] = location desc [rental_title] = prop title [rental_location] = prop location desc [rental_description] = prop desc [rental_features] = feature list [rental_reviews] = review link [rental_availability] = availability link [rental_gallery] = slideshow link [rental_weather] = weather widget [rental_extra_info] = extra info [Rate/s1_title] = 1 [Rate/s1_day] = [Rate/s1_week] = [Rate/s1_month] = [Rate/s2_title] =
Re: Unable to save related table information
You probably get the warning due to the following: [code] class Rate extends AppModel { var $name = 'Rate'; var $belongsTo = 'Rentals'; } [/code] Observe that you have given your Rental model as Rentals in the belongsTo association! Fix that and the warning should go away. Enjoy, John On Jan 15, 9:34 pm, koala kid a...@koalawebsolutions.com wrote: Thanks, that fixed it. For some reason I had Rate/ instead of Rate. in my HTML form as the input name, changing that and its now saving. Thanks for the tip. However I've now got another issue! When I submit the form the data is being saved but I get a PHP warning: Warning (2): Illegal offset type in unset [CORE/cake/libs/model/model.php, line 561] Code | Context $params = array( belongsTo = array( Location = array() ) ) $reset = true $models = array( Location = array( className = Location ) ) $assoc = belongsTo $model = array( className = Location ) foreach ($models as $model) { $this-__backAssociation = array_merge($this-__backAssociation, $this-{$assoc}); unset ($this-__backAssociation[$model]); Model::unbindModel() - CORE/cake/libs/model/model.php, line 561 RentalsController::edit() - APP/controllers/rentals_controller.php, line 91 Object::dispatchMethod() - CORE/cake/libs/object.php, line 116 Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 227 Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 194 [main] - APP/webroot/index.php, line 88 It looks like I still haven't got my head around this ORM thing. Have I set up my associations correctly? Thanks for your help. [snip] 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: Unable to save related table information
I already fixed that at some point whilst looking for the problem. My classes now look like this: class Location extends AppModel { var $name = 'Location'; var $hasMany = array( 'Rental' = array( 'className' = 'Rental', 'order' = 'Rental.created DESC' ) ); class Rental extends AppModel { var $name = 'Rental'; var $hasOne = array( 'Rate' = array( 'className'= 'Rate', 'foreignKey' = 'rental_id', 'dependent'= true ) ); var $belongsTo = array( 'Location' = array( 'className' = 'Location' ) ); } class Rate extends AppModel { var $name = 'Rate'; var $belongsTo = array( 'Rental' = array( 'className' = 'Rental' ) ); } Thanks. John Andersen-6 wrote: You probably get the warning due to the following: [code] class Rate extends AppModel { var $name = 'Rate'; var $belongsTo = 'Rentals'; } [/code] Observe that you have given your Rental model as Rentals in the belongsTo association! Fix that and the warning should go away. Enjoy, John On Jan 15, 9:34 pm, koala kid a...@koalawebsolutions.com wrote: Thanks, that fixed it. For some reason I had Rate/ instead of Rate. in my HTML form as the input name, changing that and its now saving. Thanks for the tip. However I've now got another issue! When I submit the form the data is being saved but I get a PHP warning: Warning (2): Illegal offset type in unset [CORE/cake/libs/model/model.php, line 561] Code | Context $params = array( belongsTo = array( Location = array() ) ) $reset = true $models = array( Location = array( className = Location ) ) $assoc = belongsTo $model = array( className = Location ) foreach ($models as $model) { $this-__backAssociation = array_merge($this-__backAssociation, $this-{$assoc}); unset ($this-__backAssociation[$model]); Model::unbindModel() - CORE/cake/libs/model/model.php, line 561 RentalsController::edit() - APP/controllers/rentals_controller.php, line 91 Object::dispatchMethod() - CORE/cake/libs/object.php, line 116 Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 227 Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 194 [main] - APP/webroot/index.php, line 88 It looks like I still haven't got my head around this ORM thing. Have I set up my associations correctly? Thanks for your help. [snip] 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 -- View this message in context: http://old.nabble.com/Unable-to-save-related-table-information-tp27153345p27182900.html Sent from the CakePHP mailing list archive at Nabble.com. 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: Unable to save related table information
I definitely have something funny going on with these associations, I just noticed that when I do an update on the Rentals, it creates a NEW entry in the Rate table rather than updating the entry with the correct ID. Boy this ORM stuff just confuses the hell out of me. koala kid wrote: I already fixed that at some point whilst looking for the problem. My classes now look like this: class Location extends AppModel { var $name = 'Location'; var $hasMany = array( 'Rental' = array( 'className' = 'Rental', 'order' = 'Rental.created DESC' ) ); class Rental extends AppModel { var $name = 'Rental'; var $hasOne = array( 'Rate' = array( 'className'= 'Rate', 'foreignKey' = 'rental_id', 'dependent'= true ) ); var $belongsTo = array( 'Location' = array( 'className' = 'Location' ) ); } class Rate extends AppModel { var $name = 'Rate'; var $belongsTo = array( 'Rental' = array( 'className' = 'Rental' ) ); } Thanks. John Andersen-6 wrote: You probably get the warning due to the following: [code] class Rate extends AppModel { var $name = 'Rate'; var $belongsTo = 'Rentals'; } [/code] Observe that you have given your Rental model as Rentals in the belongsTo association! Fix that and the warning should go away. Enjoy, John On Jan 15, 9:34 pm, koala kid a...@koalawebsolutions.com wrote: Thanks, that fixed it. For some reason I had Rate/ instead of Rate. in my HTML form as the input name, changing that and its now saving. Thanks for the tip. However I've now got another issue! When I submit the form the data is being saved but I get a PHP warning: Warning (2): Illegal offset type in unset [CORE/cake/libs/model/model.php, line 561] Code | Context $params = array( belongsTo = array( Location = array() ) ) $reset = true $models = array( Location = array( className = Location ) ) $assoc = belongsTo $model = array( className = Location ) foreach ($models as $model) { $this-__backAssociation = array_merge($this-__backAssociation, $this-{$assoc}); unset ($this-__backAssociation[$model]); Model::unbindModel() - CORE/cake/libs/model/model.php, line 561 RentalsController::edit() - APP/controllers/rentals_controller.php, line 91 Object::dispatchMethod() - CORE/cake/libs/object.php, line 116 Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 227 Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 194 [main] - APP/webroot/index.php, line 88 It looks like I still haven't got my head around this ORM thing. Have I set up my associations correctly? Thanks for your help. [snip] 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 -- View this message in context: http://old.nabble.com/Unable-to-save-related-table-information-tp27153345p27183004.html Sent from the CakePHP mailing list archive at Nabble.com. 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: Unable to save related table information
If you are editing an existing record, then your data must include the id, so that the model knows that it is an existing record and not a new one. If the id is not present, then the model will create a new record. So your data array for the Rate should also include the id, like this: [code] [Rate] = Array ( [id] = 8 [s1_title] = s1 Title [s1_day] = [s1_week] = [s1_month] = [s2_title] = ... [/code] Your edit form should ensure this (hidden field) or someway else. Enjoy, John On Jan 15, 10:16 pm, koala kid a...@koalawebsolutions.com wrote: I definitely have something funny going on with these associations, I just noticed that when I do an update on the Rentals, it creates a NEW entry in the Rate table rather than updating the entry with the correct ID. Boy this ORM stuff just confuses the hell out of me. koala kid wrote: I already fixed that at some point whilst looking for the problem. My classes now look like this: class Location extends AppModel { var $name = 'Location'; var $hasMany = array( 'Rental' = array( 'className' = 'Rental', 'order' = 'Rental.created DESC' ) ); class Rental extends AppModel { var $name = 'Rental'; var $hasOne = array( 'Rate' = array( 'className' = 'Rate', 'foreignKey' = 'rental_id', 'dependent' = true ) ); var $belongsTo = array( 'Location' = array( 'className' = 'Location' ) ); } class Rate extends AppModel { var $name = 'Rate'; var $belongsTo = array( 'Rental' = array( 'className' = 'Rental' ) ); } Thanks. John Andersen-6 wrote: You probably get the warning due to the following: [code] class Rate extends AppModel { var $name = 'Rate'; var $belongsTo = 'Rentals'; } [/code] Observe that you have given your Rental model as Rentals in the belongsTo association! Fix that and the warning should go away. Enjoy, John On Jan 15, 9:34 pm, koala kid a...@koalawebsolutions.com wrote: Thanks, that fixed it. For some reason I had Rate/ instead of Rate. in my HTML form as the input name, changing that and its now saving. Thanks for the tip. However I've now got another issue! When I submit the form the data is being saved but I get a PHP warning: Warning (2): Illegal offset type in unset [CORE/cake/libs/model/model.php, line 561] Code | Context $params = array( belongsTo = array( Location = array() ) ) $reset = true $models = array( Location = array( className = Location ) ) $assoc = belongsTo $model = array( className = Location ) foreach ($models as $model) { $this-__backAssociation = array_merge($this-__backAssociation, $this-{$assoc}); unset ($this-__backAssociation[$model]); Model::unbindModel() - CORE/cake/libs/model/model.php, line 561 RentalsController::edit() - APP/controllers/rentals_controller.php, line 91 Object::dispatchMethod() - CORE/cake/libs/object.php, line 116 Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 227 Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 194 [main] - APP/webroot/index.php, line 88 It looks like I still haven't got my head around this ORM thing. Have I set up my associations correctly? Thanks for your help. [snip] 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 -- View this message in context:http://old.nabble.com/Unable-to-save-related-table-information-tp2715... Sent from the CakePHP mailing list archive at Nabble.com. 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: Unable to save related table information
OK, again thanks for your help. So I have the ID being passed back as a hidden field: echo $form-input('id', array('type'='hidden', 'value' = $rental['Rental']['id'])); I thought that Cake would, due to the relationship I set up in the Model, grab the ID from Rental and pass it to Rate as rental_id. Is this not the case? Do I need to explicitly set rental_id such as: $this-data['Rate']['rental_id'] = $this-data['Rental']['id'] ?? John Andersen-6 wrote: If you are editing an existing record, then your data must include the id, so that the model knows that it is an existing record and not a new one. If the id is not present, then the model will create a new record. So your data array for the Rate should also include the id, like this: [code] [Rate] = Array ( [id] = 8 [s1_title] = s1 Title [s1_day] = [s1_week] = [s1_month] = [s2_title] = ... [/code] Your edit form should ensure this (hidden field) or someway else. Enjoy, John On Jan 15, 10:16 pm, koala kid a...@koalawebsolutions.com wrote: I definitely have something funny going on with these associations, I just noticed that when I do an update on the Rentals, it creates a NEW entry in the Rate table rather than updating the entry with the correct ID. Boy this ORM stuff just confuses the hell out of me. koala kid wrote: I already fixed that at some point whilst looking for the problem. My classes now look like this: class Location extends AppModel { var $name = 'Location'; var $hasMany = array( 'Rental' = array( 'className' = 'Rental', 'order' = 'Rental.created DESC' ) ); class Rental extends AppModel { var $name = 'Rental'; var $hasOne = array( 'Rate' = array( 'className' = 'Rate', 'foreignKey' = 'rental_id', 'dependent' = true ) ); var $belongsTo = array( 'Location' = array( 'className' = 'Location' ) ); } class Rate extends AppModel { var $name = 'Rate'; var $belongsTo = array( 'Rental' = array( 'className' = 'Rental' ) ); } Thanks. John Andersen-6 wrote: You probably get the warning due to the following: [code] class Rate extends AppModel { var $name = 'Rate'; var $belongsTo = 'Rentals'; } [/code] Observe that you have given your Rental model as Rentals in the belongsTo association! Fix that and the warning should go away. Enjoy, John On Jan 15, 9:34 pm, koala kid a...@koalawebsolutions.com wrote: Thanks, that fixed it. For some reason I had Rate/ instead of Rate. in my HTML form as the input name, changing that and its now saving. Thanks for the tip. However I've now got another issue! When I submit the form the data is being saved but I get a PHP warning: Warning (2): Illegal offset type in unset [CORE/cake/libs/model/model.php, line 561] Code | Context $params = array( belongsTo = array( Location = array() ) ) $reset = true $models = array( Location = array( className = Location ) ) $assoc = belongsTo $model = array( className = Location ) foreach ($models as $model) { $this-__backAssociation = array_merge($this-__backAssociation, $this-{$assoc}); unset ($this-__backAssociation[$model]); Model::unbindModel() - CORE/cake/libs/model/model.php, line 561 RentalsController::edit() - APP/controllers/rentals_controller.php, line 91 Object::dispatchMethod() - CORE/cake/libs/object.php, line 116 Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 227 Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 194 [main] - APP/webroot/index.php, line 88 It looks like I still haven't got my head around this ORM thing. Have I set up my associations correctly? Thanks for your help. [snip] 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 -- View this message in context:http://old.nabble.com/Unable-to-save-related-table-information-tp2715... Sent from the CakePHP mailing list archive at Nabble.com. 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
Re: Unable to save related table information
Hi, koala kid Try to add 'foreignKey' It can cause your problem. ?php class Rental extends AppModel { var $name = 'Rental'; var $hasOne = array( 'Rate' = array( 'className'= 'Rate', 'foreignKey' = 'rental_id', 'dependent'= true ) ); var $belongsTo = array( 'Location' = array( 'className' = 'Location', 'foreignKey' = 'rental_id', 'fields'= 'city' ) ); } ? Then $this-Rental-saveAll($this-data); should be work.:-P class Rate extends AppModel { var $name = 'Rate'; var $belongsTo = array( 'Rentals' = array( 'className'= 'Rate', 'foreignKey' = 'rental_id', 'dependent'= true ) } koala kid wrote: Hi all, using ORM for the first time and I'm having trouble getting my associations all worked out. I'm unable to get my associated table data to save.Here's a basic overview of my models: Locations - Parent Rentals - Belongs to Locations Rates - Belongs to Rentals My code looks like this: ?php class Rental extends AppModel { var $name = 'Rental'; var $hasOne = array( 'Rate' = array( 'className'= 'Rate', 'dependent'= true ) ); var $belongsTo = array( 'Location' = array( 'className' = 'Location', 'fields'= 'city' ) ); } ? class Rate extends AppModel { var $name = 'Rate'; var $belongsTo = 'Rentals'; } And my save looks like this: $this-Rental-saveAll($this-data) However only data to the Rental table is being saved and not to the Rate table. Can anyone tell me what I am missing. I don't have a controller for Rates as there are no direct functions to run against them, does this matter? Thanks. -- View this message in context: http://old.nabble.com/Unable-to-save-related-table-information-tp27153345p27156458.html Sent from the CakePHP mailing list archive at Nabble.com. 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: Unable to save related table information
Thanks for your input. It looks like below. I think I may have the Model name in the wrong place?? I'm using: echo $form-create('Rental', array('type' = 'file', 'action' = 'edit')); to create the form. Array ( [Rental] = Array ( [id] = 60 [rental_code] = code [location_id] = 37 [rental_agent] = a...@gmail.com [rental_meta_title] = meta title [rental_meta_desc] = meta desc [rental_meta_tags] = meta kewords [rental_short_title] = location title [rental_short_desc] = location desc [rental_title] = prop title [rental_location] = prop location desc [rental_description] = prop desc [rental_features] = feature list [rental_reviews] = review link [rental_availability] = availability link [rental_gallery] = slideshow link [rental_weather] = weather widget [rental_extra_info] = extra info [Rate/s1_title] = 1 [Rate/s1_day] = [Rate/s1_week] = [Rate/s1_month] = [Rate/s2_title] = [Rate/s2_day] = [Rate/s2_week] = [Rate/s2_month] = [Rate/s3_title] = [Rate/s3_day] = [Rate/s3_week] = [Rate/s3_month] = [Rate/s4_title] = [Rate/s4_day] = [Rate/s4_week] = [Rate/s4_month] = [Rate/extra_info] = [rental_short_thumb] = holder.gif ) ) John Andersen-6 wrote: How does your data look like before the saveAll statement? Enjoy, John On Jan 14, 12:41 am, koala kid a...@koalawebsolutions.com wrote: Hi all, using ORM for the first time and I'm having trouble getting my associations all worked out. I'm unable to get my associated table data to save.Here's a basic overview of my models: Locations - Parent Rentals - Belongs to Locations Rates - Belongs to Rentals My code looks like this: ?php class Rental extends AppModel { var $name = 'Rental'; var $hasOne = array( 'Rate' = array( 'className' = 'Rate', 'dependent' = true ) ); var $belongsTo = array( 'Location' = array( 'className' = 'Location', 'fields' = 'city' ) ); } ? class Rate extends AppModel { var $name = 'Rate'; var $belongsTo = 'Rentals'; } And my save looks like this: $this-Rental-saveAll($this-data) However only data to the Rental table is being saved and not to the Rate table. Can anyone tell me what I am missing. I don't have a controller for Rates as there are no direct functions to run against them, does this matter? Thanks. -- View this message in context:http://old.nabble.com/Unable-to-save-related-table-information-tp2715... Sent from the CakePHP mailing list archive at Nabble.com. 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 -- View this message in context: http://old.nabble.com/Unable-to-save-related-table-information-tp27153345p27170133.html Sent from the CakePHP mailing list archive at Nabble.com. 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: Unable to save related table information
Hi, thanks for your suggestion. I tried it but I am still having the same problem. Nadal wrote: Hi, koala kid Try to add 'foreignKey' It can cause your problem. ?php class Rental extends AppModel { var $name = 'Rental'; var $hasOne = array( 'Rate' = array( 'className'= 'Rate', 'foreignKey' = 'rental_id', 'dependent'= true ) ); var $belongsTo = array( 'Location' = array( 'className' = 'Location', 'foreignKey' = 'rental_id', 'fields'= 'city' ) ); } ? Then $this-Rental-saveAll($this-data); should be work.:-P class Rate extends AppModel { var $name = 'Rate'; var $belongsTo = array( 'Rentals' = array( 'className'= 'Rate', 'foreignKey' = 'rental_id', 'dependent'= true ) } koala kid wrote: Hi all, using ORM for the first time and I'm having trouble getting my associations all worked out. I'm unable to get my associated table data to save.Here's a basic overview of my models: Locations - Parent Rentals - Belongs to Locations Rates - Belongs to Rentals My code looks like this: ?php class Rental extends AppModel { var $name = 'Rental'; var $hasOne = array( 'Rate' = array( 'className'= 'Rate', 'dependent'= true ) ); var $belongsTo = array( 'Location' = array( 'className' = 'Location', 'fields'= 'city' ) ); } ? class Rate extends AppModel { var $name = 'Rate'; var $belongsTo = 'Rentals'; } And my save looks like this: $this-Rental-saveAll($this-data) However only data to the Rental table is being saved and not to the Rate table. Can anyone tell me what I am missing. I don't have a controller for Rates as there are no direct functions to run against them, does this matter? Thanks. -- View this message in context: http://old.nabble.com/Unable-to-save-related-table-information-tp27153345p27170148.html Sent from the CakePHP mailing list archive at Nabble.com. 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: Unable to save related table information
How does your data look like before the saveAll statement? Enjoy, John On Jan 14, 12:41 am, koala kid a...@koalawebsolutions.com wrote: Hi all, using ORM for the first time and I'm having trouble getting my associations all worked out. I'm unable to get my associated table data to save.Here's a basic overview of my models: Locations - Parent Rentals - Belongs to Locations Rates - Belongs to Rentals My code looks like this: ?php class Rental extends AppModel { var $name = 'Rental'; var $hasOne = array( 'Rate' = array( 'className' = 'Rate', 'dependent' = true ) ); var $belongsTo = array( 'Location' = array( 'className' = 'Location', 'fields' = 'city' ) ); } ? class Rate extends AppModel { var $name = 'Rate'; var $belongsTo = 'Rentals'; } And my save looks like this: $this-Rental-saveAll($this-data) However only data to the Rental table is being saved and not to the Rate table. Can anyone tell me what I am missing. I don't have a controller for Rates as there are no direct functions to run against them, does this matter? Thanks. -- View this message in context:http://old.nabble.com/Unable-to-save-related-table-information-tp2715... Sent from the CakePHP mailing list archive at Nabble.com. 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