Missing Controller Error
I've just installed CakePHP and trying to get myself through Andrewperk's blog tutorial but I get this error after the second video... Missing Controller Error: PostsController could not be found. Error: Create the class PostsController below in file: app/Controller/ PostsController.php ?php class PostsController extends AppController { } I've tried to Google my way out of this one but don't have the technical expertise to comprehend the suggestions I find. I'm assuming my routes are a bit f'd up so if anyone could help me I would be greatly appreciative. Sincerely, A Noob BTW I'm using XAMPP on a Mac 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
app/tmp permissions
I'm a total newbie to Cake and believe I've put everything in their proper folders. Everything is green on my local host except my tmp Directory is not writable (yellow) I have no idea how to set permissions and have tried chmod in terminal but really not sure even if I'm doing this part properly. Any step by step would be much appreciated. 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
Re: hiding link from certain users.
thank you for your reply..but i still can't get it right.. I'm a slow learner. Can you please explain deeper on the (Auth.User.group_id') part. this is what the table in db looks like id usrname pass superuser 1 jill 123451 2 john 543210 3 kurt 32145 0 On Wed, Feb 23, 2011 at 7:42 PM, Stephen step...@ninjacodermonkey.co.ukwrote: $session-read('Auth.User.column'); You can access the user's record from within a view like the above, so as long as your group is specified in the user record (say ... group_id) if($session-read('Auth.User.group_id') == 'superuser') { } This assumes you are using the Auth component. -- Kind Regards Stephen @ NinjaCoderMonkey www.ninjacodermonkey.co.uk -- 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
hiding link from certain users.
Hello again. My web application has several group of users. 1. user 2. superuser I've created a page where only superuser can access and was successful. But my problem is the link in default.ctp that direct users to that page are still visible to normal user after login. I just want the link to be visible for superuser.. I was thinking of something similar to this.. after login: if ($user = 'superuser') { echo $html-link (__('System Setting',true), array ('controller'='committees','action'='setpages')) } but I'm not sure how to apply it to cakephp framework.. i need help and guide, i'm a newbie... thank you! -- 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
adding a new link and view to a cakephp websites
hello there.. I've been having troubles modifying a website which uses cakephp framework. I'm trying to add new link button that will show a new view in the content div.. I've made the link in the nav bar, but i'm out of ideas where to create the new view. I made a new .ctp files in the view folder and use the existing controller where i added another function inside the controller. I want the nav bar, the color n everything else stays only the content div change.. : ?php echo $html-link (__('System Setting',true), array ('controller'='committees','action'='setpages')) ? when i create a div in the setpages.ctp and the css file, nothing comes out. I'm also truly, madly, deeply confused with $content_for_layout! where is it? what's actually in it? how can i edit it? I'm a slow poke snail... T_T having hard time understanding the manual. thank you and please help me. sorry for my bad english^^ *peace no war* -- 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: adding a new link and view to a cakephp websites
Thanks Ken! You are right, I've been given tasks to modify an open source web application which are based on cakephp framework. I know a bit about php, but still can't manage to get my head on to cakephp. I'll try the link you have given and review again the whole manual.. thanks again for the advices!! On Tue, Feb 22, 2011 at 1:16 PM, kdubya kenwin...@winanstech.com wrote: Based on the (very small) snippet of code you posted, the view should be placed in the /app/views/committees directory and the file should be named setpages.ctp. The layout will have the $content_for_layout in it. Look in /app/views/ layouts. It may be a file called default.ctp (but maybe not). When the page is rendered, the contents of the setpages.ctp file will be inserted in the layout at the position of $content_for_layout. Since it seems you are trying to modify someone else's CakePHP application, you may not have spent enough time with the tutorial in the Manual. This is a mistake. I highly recommend you go through the tutorial BEFORE trying to modify existing CakePHP code. Go to: http://book.cakephp.org/#!/view/1528/Blog Good luck, Ken -- 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
Changing the layout and appearance
Hello, I'm new to cake php but i know a bit bout basic php.. I understand the MVC concept i think^^, i need to change the whole appearance and layout of a site powered by cakePhp..where can i find the file that controls the structure and appearance of the pages and how?? Sorry for my noobness.. tq all^^ -- 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: Can someone explain ORM
Hi Paul, been on holiday for a week. Here's the error I am getting: $sql= SELECT `Cat`.`id`, `Cat`.`title`, `Cat`.`location_id`, `Cat`.`created`, `Cat`.`modified` FROM `cats` AS `Cat` WHERE `Subcat`.`cat_id` = `Cat`.`id` $error = 1054: Unknown column 'Subcat.cat_id' in 'where clause' LocalInfosController::admin_index() - APP/controllers/ local_infos_controller.php, line 60 Here's the index function: function admin_index(){ $this-LocalInfo-bindModel(array('belongsTo'=array( 'Cat'=array( 'foreignKey'=false, 'type'='INNER', 'conditions'=array('Subcat.cat_id = Cat.id') ), 'Location'=array( 'foreignKey'=false, 'type'='INNER', 'conditions'=array('LocalInfo.location_id = Location.id') ) )), false); $this-set('local', $this-paginate('LocalInfo')); } Here are my classes and associations: class Cat extends AppModel { var $name = 'Cat'; var $belongsTo = 'Location'; var $hasMany = array( 'Subcat' = array( 'className' = 'Subcat', 'foreignKey'= 'cat_id' ) ); } class Subcat extends AppModel { var $name = 'Subcat'; var $belongsTo = array( 'Cat' = array( 'className' = 'Cat', 'foreignKey'= 'cat_id' ) ); var $hasMany = array( 'LocalInfo' = array( 'className' = 'LocalInfo', 'foreignKey' = 'subcat_id' ) ); } class LocalInfo extends AppModel { var $name = 'LocalInfo'; var $belongsTo = array( 'SubCat' = array( 'className'= 'Subcat', 'foreignKey'= 'subcat_id' ) ); } On Feb 16, 1:04 am, WebbedIT p...@webbedit.co.uk wrote: Something going wrong in your associations or bindings as Subcat.cat_id is in a directly related model. Can you supply the associations for the model you are running find from, then your bindings you are applying, the find command you are running and the resulting SQL that it's having problems with? Paul. 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: Can someone explain ORM
Hi Paul, been on holiday for a week. Here's the error I am getting: $sql= SELECT `Cat`.`id`, `Cat`.`title`, `Cat`.`location_id`, `Cat`.`created`, `Cat`.`modified` FROM `cats` AS `Cat` WHERE `Subcat`.`cat_id` = `Cat`.`id` $error = 1054: Unknown column 'Subcat.cat_id' in 'where clause' LocalInfosController::admin_index() - APP/controllers/ local_infos_controller.php, line 60 Here's the index function: function admin_index(){ $this-LocalInfo-bindModel(array('belongsTo'=array( 'Cat'=array( 'foreignKey'=false, 'type'='INNER', 'conditions'=array('Subcat.cat_id = Cat.id') ), 'Location'=array( 'foreignKey'=false, 'type'='INNER', 'conditions'=array('LocalInfo.location_id = Location.id') ) )), false); $this-set('local', $this-paginate('LocalInfo')); } Here are my classes and associations: class Cat extends AppModel { var $name = 'Cat'; var $belongsTo = 'Location'; var $hasMany = array( 'Subcat' = array( 'className' = 'Subcat', 'foreignKey'= 'cat_id' ) ); } class Subcat extends AppModel { var $name = 'Subcat'; var $belongsTo = array( 'Cat' = array( 'className' = 'Cat', 'foreignKey'= 'cat_id' ) ); var $hasMany = array( 'LocalInfo' = array( 'className' = 'LocalInfo', 'foreignKey' = 'subcat_id' ) ); } class LocalInfo extends AppModel { var $name = 'LocalInfo'; var $belongsTo = array( 'SubCat' = array( 'className'= 'Subcat', 'foreignKey'= 'subcat_id' ) ); } On Feb 16, 1:04 am, WebbedIT p...@webbedit.co.uk wrote: Something going wrong in your associations or bindings as Subcat.cat_id is in a directly related model. Can you supply the associations for the model you are running find from, then your bindings you are applying, the find command you are running and the resulting SQL that it's having problems with? Paul. 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: Can someone explain ORM
Thanks for your response. Changing true = false still throws some errors (below) but it seems to work?? Warning (512): SQL Error: 1054: Unknown column 'Subcat.cat_id' in 'where clause' [CORE/cake/libs/model/datasources/dbo_source.php, line 525] Warning (512): SQL Error: 1054: Unknown column 'Cat.location_id' in 'where clause' [CORE/cake/libs/model/datasources/dbo_source.php, line 525] When I tried your contain option I get this: Model LocalInfo is not associated with model Subcat [CORE/cake/ libs/model/behaviors/containable.php, line 340] Any ideas? On Feb 13, 2:57 am, WebbedIT p...@webbedit.co.uk wrote: When using pagination with on the fly binds you need to specify the last parameter as false to make the bind last for multiple queries. $this-LocalInfo-bindModel(array('belongsTo'=array( 'Cat'=array( 'foreignKey'=false, 'type'='INNER', 'conditions'=array('Subcat.cat_id = Cat.id') ), 'Location'=array( 'foreignKey'=false, 'type'='INNER', 'conditions'=array('Cat.location_id = Location.id') ) )), false); When using contain and specifying deep relations they need to be done as follows $this-LocalInfo-Behaviors-attach('Containable'); $this-paginate['LocalInfo'] = array( 'contain' = array('Subcat'=array( 'Cat'=array( 'Location' ) )), 'order' = 'LocalInfo.title' ); 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: Can someone explain ORM
Paul, sorry for the late reply, I wasn't notified of your response. Your trick worked like a charm, thanks man, I've been scratching my head over this for ages. So it's not just me going crazy then, I am having problems in a few places getting ORM to return my results, as I am newish to Cake I kept thinking I must be doing something wrong, its nice to know I'm not a complete idiot. Thanks. On Feb 11, 3:41 am, WebbedIT p...@webbedit.co.uk wrote: Now people keep telling me that I am wrong here, but I have always had problems with deep belongsTo associations not being fetched with recursive alone. In your instance LocalInfo belongsTo Subcat which belongsTo Cat which belongsTo Location and your find recursive stops after the first belongsTo only finding LocalInfo and Subcat. There are a few things you can do. 1. Force a join from LocalInfo to Cat by doing the following in the controller before the find $this-LocalInfo-bindModel(array('belongsTo'=array( 'Cat'=array( 'foreignKey'=false, 'type'='INNER', 'conditions'=array('Subcat.cat_id = Cat.id') ) )), true); The last condition defaults to true so you dont actually need to pass it, but if your paginating results needs to be set to true to make the bind persistent otherwise the bind only exists for the first find that follows it. If you need also need data from Location you would need to bind that too as follows: $this-LocalInfo-bindModel(array('belongsTo'=array( 'Cat'=array( 'foreignKey'=false, 'type'='INNER', 'conditions'=array('Subcat.cat_id = Cat.id') ), 'Location'=array( 'foreignKey'=false, 'type'='INNER', 'conditions'=array('Cat.location_id = Location.id') ) )), true); 2. The 2nd option is to use containable, which I use all the time and is great as long as you're not needing to place any conditions on the deep tables, in which case you must do the above. http://book.cakephp.org/view/474/Containable HTH Paul. 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: Saving related table data
Hi John, thanks for your fix, its now working. I had assumed that as I was defining the relationship as a hasOne and belongsTo Cake would automatically know to Update rather than Insert as it was a 1 - 1 relationship, using the Rental.id. This is where I am really struggling with Cake, so much is taken care for you that you don't know where it stops, and the documentation, although much improved, still makes it hard on occasion to find out. Anyway thanks again. On Feb 11, 3:02 am, John Andersen j.andersen...@gmail.com wrote: Your problem lies in this part: [Rate] = Array ( [s1_title] = title 1 [s1_day] = day 1 [s1_week] = [s1_month] = [extra_info] = ) I assume that this information was at first retrieved from the database and presented to the user. The user then changed something and saved. The above information lacks the Rate.id information - without which CakePHP assumes that you are saving a new record in the Rate model. You have to add the Rate.id as a hidden field in the view (worst solution) or get it from somewhere else. Hope this will help you on the way, John On Feb 10, 8:09 pm, koala kid alexhob...@gmail.com wrote: Hi, I'm still struggling with saving information to related tables. I have a form which updates info about a rental property and I have an associated Rates table which holds data about the rental rates for the property. I've defined my relationship as : Rental - hasOne Rate - belongsTo My save action looks like this: $this-Rental-saveAll($this-data); However this save action is creating a new entry in the Rates table rather than updating the existing one. I'm pretty sure my form data is in the correct format: Array ( [Rental] = Array ( [id] = 45 [rental_code] = PDSSerena [location_id] = 19 [rental_agent] = [rental_meta_url] = [rental_meta_title] = [rental_meta_desc] = [rental_meta_tags] = ) [Rate] = Array ( [s1_title] = title 1 [s1_day] = day 1 [s1_week] = [s1_month] = [extra_info] = ) ) Do I need to explicitly set the rental_id in my Rate form data, such as: [Rate] = Array ( [rental_id] = 45 ) 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: Can someone explain ORM
Paul, I was just trying your bindModel trick on the index function of the same controller, but this one uses the Paginator component to make it easier for the user to sort through results. However doing this the bind doesn't seem to be taking place as I am getting SQL errors. Any suggestions? Warning (512): SQL Error: 1054: Unknown column 'Subcat.cat_id' in 'where clause' [CORE/cake/libs/model/datasources/dbo_source.php, line 525] $sql= SELECT `Cat`.`id`, `Cat`.`title`, `Cat`.`location_id`, `Cat`.`created`, `Cat`.`modified` FROM `cats` AS `Cat` WHERE `Subcat`.`cat_id` = `Cat`.`id` $error = 1054: Unknown column 'Subcat.cat_id' in 'where clause' $sql= SELECT `Location`.`id`, `Location`.`city`, `Location`.`state`, `Location`.`country`, `Location`.`info`, `Location`.`order`, `Location`.`meta_url`, `Location`.`meta_title`, `Location`.`meta_desc`, `Location`.`meta_tags`, `Location`.`created`, `Location`.`modified` FROM `locations` AS `Location` WHERE `Cat`.`location_id` = `Location`.`id` $error = 1054: Unknown column 'Cat.location_id' in 'where clause' On Feb 12, 11:45 am, koala kid alexhob...@gmail.com wrote: Paul, sorry for the late reply, I wasn't notified of your response. Your trick worked like a charm, thanks man, I've been scratching my head over this for ages. So it's not just me going crazy then, I am having problems in a few places getting ORM to return my results, as I am newish to Cake I kept thinking I must be doing something wrong, its nice to know I'm not a complete idiot. Thanks. On Feb 11, 3:41 am, WebbedIT p...@webbedit.co.uk wrote: Now people keep telling me that I am wrong here, but I have always had problems with deep belongsTo associations not being fetched with recursive alone. In your instance LocalInfo belongsTo Subcat which belongsTo Cat which belongsTo Location and your find recursive stops after the first belongsTo only finding LocalInfo and Subcat. There are a few things you can do. 1. Force a join from LocalInfo to Cat by doing the following in the controller before the find $this-LocalInfo-bindModel(array('belongsTo'=array( 'Cat'=array( 'foreignKey'=false, 'type'='INNER', 'conditions'=array('Subcat.cat_id = Cat.id') ) )), true); The last condition defaults to true so you dont actually need to pass it, but if your paginating results needs to be set to true to make the bind persistent otherwise the bind only exists for the first find that follows it. If you need also need data from Location you would need to bind that too as follows: $this-LocalInfo-bindModel(array('belongsTo'=array( 'Cat'=array( 'foreignKey'=false, 'type'='INNER', 'conditions'=array('Subcat.cat_id = Cat.id') ), 'Location'=array( 'foreignKey'=false, 'type'='INNER', 'conditions'=array('Cat.location_id = Location.id') ) )), true); 2. The 2nd option is to use containable, which I use all the time and is great as long as you're not needing to place any conditions on the deep tables, in which case you must do the above. http://book.cakephp.org/view/474/Containable HTH Paul. 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: Can someone explain ORM
I just tried using Containable: $this-LocalInfo-Behaviors-attach('Containable'); $this-paginate['LocalInfo'] = array( 'contain' = array('Subcat', 'Cat', 'Location'), 'order' = 'LocalInfo.title' ); but got these errors: Warning (512): Model LocalInfo is not associated with model Subcat [CORE/cake/libs/model/behaviors/containable.php, line 340] Warning (512): Model LocalInfo is not associated with model Cat [CORE/cake/libs/model/behaviors/containable.php, line 340] Warning (512): Model LocalInfo is not associated with model Location [CORE/cake/libs/model/behaviors/containable.php, line 340] On Feb 12, 2:54 pm, koala kid alexhob...@gmail.com wrote: Paul, I was just trying your bindModel trick on the index function of the same controller, but this one uses the Paginator component to make it easier for the user to sort through results. However doing this the bind doesn't seem to be taking place as I am getting SQL errors. Any suggestions? Warning (512): SQL Error: 1054: Unknown column 'Subcat.cat_id' in 'where clause' [CORE/cake/libs/model/datasources/dbo_source.php, line 525] $sql = SELECT `Cat`.`id`, `Cat`.`title`, `Cat`.`location_id`, `Cat`.`created`, `Cat`.`modified` FROM `cats` AS `Cat` WHERE `Subcat`.`cat_id` = `Cat`.`id` $error = 1054: Unknown column 'Subcat.cat_id' in 'where clause' $sql = SELECT `Location`.`id`, `Location`.`city`, `Location`.`state`, `Location`.`country`, `Location`.`info`, `Location`.`order`, `Location`.`meta_url`, `Location`.`meta_title`, `Location`.`meta_desc`, `Location`.`meta_tags`, `Location`.`created`, `Location`.`modified` FROM `locations` AS `Location` WHERE `Cat`.`location_id` = `Location`.`id` $error = 1054: Unknown column 'Cat.location_id' in 'where clause' On Feb 12, 11:45 am, koala kid alexhob...@gmail.com wrote: Paul, sorry for the late reply, I wasn't notified of your response. Your trick worked like a charm, thanks man, I've been scratching my head over this for ages. So it's not just me going crazy then, I am having problems in a few places getting ORM to return my results, as I am newish to Cake I kept thinking I must be doing something wrong, its nice to know I'm not a complete idiot. Thanks. On Feb 11, 3:41 am, WebbedIT p...@webbedit.co.uk wrote: Now people keep telling me that I am wrong here, but I have always had problems with deep belongsTo associations not being fetched with recursive alone. In your instance LocalInfo belongsTo Subcat which belongsTo Cat which belongsTo Location and your find recursive stops after the first belongsTo only finding LocalInfo and Subcat. There are a few things you can do. 1. Force a join from LocalInfo to Cat by doing the following in the controller before the find $this-LocalInfo-bindModel(array('belongsTo'=array( 'Cat'=array( 'foreignKey'=false, 'type'='INNER', 'conditions'=array('Subcat.cat_id = Cat.id') ) )), true); The last condition defaults to true so you dont actually need to pass it, but if your paginating results needs to be set to true to make the bind persistent otherwise the bind only exists for the first find that follows it. If you need also need data from Location you would need to bind that too as follows: $this-LocalInfo-bindModel(array('belongsTo'=array( 'Cat'=array( 'foreignKey'=false, 'type'='INNER', 'conditions'=array('Subcat.cat_id = Cat.id') ), 'Location'=array( 'foreignKey'=false, 'type'='INNER', 'conditions'=array('Cat.location_id = Location.id') ) )), true); 2. The 2nd option is to use containable, which I use all the time and is great as long as you're not needing to place any conditions on the deep tables, in which case you must do the above. http://book.cakephp.org/view/474/Containable HTH Paul. 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
Can someone explain ORM
Hi, can someone explain what basic fundamental of ORM I am missing? I am having trouble getting Cake to return the data I am after from Associated models even though I am pretty sure I have my associations set correctly: Location hasMany - Cat Cat: belongsTo - Location hasMany - Subcat Subcat : belongsTo - Cat hasMany - LocalInfo LocalInfo: belongsTo-Subcat However when I run the query below it only returns LocalInfo and Subcat data. I thought that by setting recursive = 2 it would bring back all associated data, including up the chain to Location. Is that not correct? $params = array('recursive' = 2); $listing = $this-LocalInfo-find('first', $params); 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
Saving related table data
Hi, I'm still struggling with saving information to related tables. I have a form which updates info about a rental property and I have an associated Rates table which holds data about the rental rates for the property. I've defined my relationship as : Rental - hasOne Rate - belongsTo My save action looks like this: $this-Rental-saveAll($this-data); However this save action is creating a new entry in the Rates table rather than updating the existing one. I'm pretty sure my form data is in the correct format: Array ( [Rental] = Array ( [id] = 45 [rental_code] = PDSSerena [location_id] = 19 [rental_agent] = [rental_meta_url] = [rental_meta_title] = [rental_meta_desc] = [rental_meta_tags] = ) [Rate] = Array ( [s1_title] = title 1 [s1_day] = day 1 [s1_week] = [s1_month] = [extra_info] = ) ) Do I need to explicitly set the rental_id in my Rate form data, such as: [Rate] = Array ( [rental_id] = 45 ) 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
How do I see a SQL statement?
I am getting the SQL error below but its not showing me the actual SQL statement that Cake is generating. Is there any way of seeing what it is? Warning (512): SQL Error: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'updateOrder' at line 1 [CORE/cake/libs/model/datasources/dbo_source.php. My controller line is: $this-Special-updateOrder($this-data)); which is calling the updateOrder in my model, which is: function updateOrder($data){ $flag = true; foreach ($data['Special'] as $key=$value): $this-id = $key; if(!$this-saveField('order', $value['order'])): $flag = false; endif; endforeach; return $flag; } My data looks like: Array ( [Special] = Array ( [1] = Array ( [order] = 0 ) [4] = Array ( [order] = 1 ) ) ) -- View this message in context: http://old.nabble.com/How-do-I-see-a-SQL-statement--tp27217643p27217643.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, 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] = [Rate
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
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
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
Unable to save related table information
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-tp27153345p27153345.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
ORM Help - Unable to save related table information
Hey all, using ORM for the first time and I'm having trouble getting my associations all worked out. Here's a basic overview of my models: Rentals - Property with whole bunch of fields Rates - Belongs to Rentals LocationsPage - 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 ), 'LocationsPage' = array( 'className'= 'LocationsPage', 'dependent'= true ) ); var $belongsTo = array( 'Location' = array( 'className' = 'Location', 'fields'= 'city' ) ); } ? class Rate extends AppModel { var $name = 'Rate'; var $belongsTo = 'Rentals'; } ?php class LocationsPage extends AppModel { var $name = 'LocationsPage'; 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 the other two. Can anyone tell me what I am missing. I don't have a controller for either Rates or LocationsPages as there are no direct functions to run against them, does this matter? 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
auto submit sitemap to Google
Hi, I am working on a site for a client using cakePHP. I found a great article in the bakery that outputs the sitemap in the correct XML format and is accessible via the browser. I want to automate the submission of this using a cron job. Does anyone have an example script that would call the xml file and send it to the http address that Google provides specifically for this? 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: action parameters lost after data validation
Thanks for your reply. My validation has become a little more complicated since yesterday as I am trying to validate 1 field but that field belongs to related model. In that case where should I perform the validation and how would I pass the ID back most effectively. On Mar 17, 8:50 pm, brian bally.z...@gmail.com wrote: On Tue, Mar 17, 2009 at 4:12 PM,koalakidalexhob...@gmail.com wrote: Hi, I am fairly new to cake and I'm making some fixes for a client on a CMS tool someone developed for them using cake. I am trying to add a custom validation rule on one of the forms but if it fails the ID parameter in the URL is being lost and the edit fails to update. Do I have to explicitly pass the ID back along? I doubt that validation has anything directly to do with it. I'm guessing your action/method has an $id as a parameter and the form action does not include it. If you're using $form-create() can you post that? Also the method itself. It's possible that it's being set the first time around but, when validation fails and the form is re-displayed, the ID var isn't set again. --~--~-~--~~~---~--~~ 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 remove the action name from the URL
I am making some changes to a CMS someone else has developed using cake. Currently all pages are served up using a controller called sites so any given url will look like: /sites/page-id However is there a way using Routes to direct the simple /page-id to the sites controller. My Routes currently looks like this: Router::connect('/', array('controller' = 'sites', 'action' = 'index')); Router::connect('/sites/*', array('controller' = 'sites', 'action' = 'page')); --~--~-~--~~~---~--~~ 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: how to remove the action name from the URL
Thanks for the reply. I tried that but I just get a timeout error. My Routes looks like this: Router::connect('/', array('controller' = 'sites', 'action' = 'index')); Router::connect('/*', array('controller' = 'sites', 'action' = 'page')); On Mar 18, 1:25 pm, dr. Hannibal Lecter lecter...@gmail.com wrote: How about: Router::connect('/*', array('controller' = 'sites', 'action' = 'page')); Of course, you need to consider the option when someone doesn't send you the page-id.. On Mar 18, 6:00 pm,koalakidalexhob...@gmail.com wrote: I am making some changes to a CMS someone else has developed using cake. Currently all pages are served up using a controller called sites so any given url will look like: /sites/page-id However is there a way using Routes to direct the simple /page-id to the sites controller. My Routes currently looks like this: Router::connect('/', array('controller' = 'sites', 'action' = 'index')); Router::connect('/sites/*', array('controller' = 'sites', 'action' = 'page')); --~--~-~--~~~---~--~~ 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: how to remove the action name from the URL
OK, thanks for your patience on this. You were right the first time, using /* will work. However when I do this I start getting timeouts. I worked out that the sites_controller was calling other controllers using the requestAction() function. By adding all these controllers to the Routes I managed to get the front end working. However the CMS backend uses the Admin routing option so now the backend is not working, the same timeout issue. I've tried adding some of the controllers to the Routes and testing them but its still not working. Have you got any suggestions? Thanks a lot for your help by the way. On Mar 18, 2:52 pm, dr. Hannibal Lecter lecter...@gmail.com wrote: Try removing that first route.. On Mar 18, 7:11 pm,koalakidalexhob...@gmail.com wrote: Thanks for the reply. I tried that but I just get a timeout error. My Routes looks like this: Router::connect('/', array('controller' = 'sites', 'action' = 'index')); Router::connect('/*', array('controller' = 'sites', 'action' = 'page')); On Mar 18, 1:25 pm, dr. Hannibal Lecter lecter...@gmail.com wrote: How about: Router::connect('/*', array('controller' = 'sites', 'action' = 'page')); Of course, you need to consider the option when someone doesn't send you the page-id.. On Mar 18, 6:00 pm,koalakidalexhob...@gmail.com wrote: I am making some changes to a CMS someone else has developed using cake. Currently all pages are served up using a controller called sites so any given url will look like: /sites/page-id However is there a way using Routes to direct the simple /page-id to the sites controller. My Routes currently looks like this: Router::connect('/', array('controller' = 'sites', 'action' = 'index')); Router::connect('/sites/*', array('controller' = 'sites', 'action' = 'page')); --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
action parameters lost after data validation
Hi, I am fairly new to cake and I'm making some fixes for a client on a CMS tool someone developed for them using cake. I am trying to add a custom validation rule on one of the forms but if it fails the ID parameter in the URL is being lost and the edit fails to update. Do I have to explicitly pass the ID back along? 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
image upload - anything over than phpThumb
Hi all, I've tired in vain all day to upload an image via a form to my site. I've tried using the phpThumb Component (http://bakery.cakephp.org/ articles/view/phpthumb-component) and also manually via $_FILES. I keep getting an error such as the one below, which is from the component: [0] = Can not write to target directory [/path-to-my-dir/html/app/ webroot/img/thumb/] I would really appreciate any assistance I could get or some code that is proven to work. The directory has write permissions 777. 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Form validation - multiple forms and multiple tables used per model
Hi, thanks for your help, its really appreciated. I'm new to cake and although I know its going to be beneficial in the long run right now the learning curve sucks and what really makes it worse is the lack of decent documentation. For example the behaviour you gave me the link to seems to do exactly what I need but it doesn't tell me where to save it and what to call the file. Can you explain? Thanks. On Jun 17, 6:03 am, keymaster [EMAIL PROTECTED] wrote: How do I run cake's validation methods on each form separately. At the moment you appear to define your rules in $validate outside of any functions/methods. How do I run it from within a method. Use this behavior: http://bakery.cakephp.org/articles/view/using-many-validation-ruleset... --~--~-~--~~~---~--~~ 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: Form validation - multiple forms and multiple tables used per model
Ok, I dug around and found out what to name the file and where to save it, I think. I saved the file as multi_validate.php in app/models/ behaviours/. Is this correct? I then defined my rules eg: var $validationSets = array( 'admin' = array( 'name' = array('rule' = 'alphanumeric'), 'email' = array('rule' = 'email'), 'age' = array('rule' = 'numeric'), ), 'prop_add' = array( 'prop_code' = array('rule' = 'alphanumeric'), 'city' = array('rule' = 'alphanumeric'), 'prop_page_title' = array('rule' = 'alphanumeric'), 'prop_page_desc' = array('rule' = 'alphanumeric'), 'prop_title' = array('rule' = 'alphanumeric'), 'prop_location' = array('rule' = 'alphanumeric'), 'prop_description' = array('rule' = 'alphanumeric'), 'prop_features' = array('rule' = 'alphanumeric'), 'prop_reviews' = array('rule' = 'alphanumeric'), 'prop_availability' = array('rule' = 'alphanumeric'), 'prop_flickr' = array('rule' = 'alphanumeric') ), 'addNewLocation' = array( 'city' = array('rule' = 'alphanumeric', 'message' = 'Only letters and numbers, please try again.'), 'state' = array('rule' = array('minLenght', 6), 'message' = 'Password must be at least 6 characters long, please try again.') ) ); I then set which set of rules to use within my method like this: $this-Admin-setValidation('prop_add'); but the form submits without validating. Any ideas where I am going wrong? Thanks. On Jun 17, 11:06 am, koala kid [EMAIL PROTECTED] wrote: Hi, thanks for your help, its really appreciated. I'm new to cake and although I know its going to be beneficial in the long run right now the learning curve sucks and what really makes it worse is the lack of decent documentation. For example the behaviour you gave me the link to seems to do exactly what I need but it doesn't tell me where to save it and what to call the file. Can you explain? Thanks. On Jun 17, 6:03 am, keymaster [EMAIL PROTECTED] wrote: How do I run cake's validation methods on each form separately. At the moment you appear to define your rules in $validate outside of any functions/methods. How do I run it from within a method. Use this behavior: http://bakery.cakephp.org/articles/view/using-many-validation-ruleset... --~--~-~--~~~---~--~~ 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: Form validation - multiple forms and multiple tables used per model
OK, I think I worked out what to name the file and where to save it: app/models/behaviours/multi_validate.php. However I can't get it to work. The form submits without validating. I first set my validation rules in the model eg: var $actsAs = array('MultiValidatable'); /** * Default validation ruleset */ var $validate = array( 'username' = array('rule' = 'alphanumeric', 'message' = 'Only letters and numbers please.'), 'password' = array('rule' = array('minLenght', 6), 'message' = 'Password must be at least 6 characters long.') //'email' = array('rule' = 'email', 'message' = 'Must be a valid email address.'), ); /** * Custom validation rulesets */ var $validationSets = array( 'admin' = array( 'name' = array('rule' = 'alphanumeric'), 'email' = array('rule' = 'email'), 'age' = array('rule' = 'numeric'), ), 'prop_add' = array( 'prop_code' = array('rule' = 'alphanumeric'), 'city' = array('rule' = 'alphanumeric'), 'prop_page_title' = array('rule' = 'alphanumeric'), 'prop_page_desc' = array('rule' = 'alphanumeric'), 'prop_title' = array('rule' = 'alphanumeric'), 'prop_location' = array('rule' = 'alphanumeric'), 'prop_description' = array('rule' = 'alphanumeric'), 'prop_features' = array('rule' = 'alphanumeric'), 'prop_reviews' = array('rule' = 'alphanumeric'), 'prop_availability' = array('rule' = 'alphanumeric'), 'prop_flickr' = array('rule' = 'alphanumeric') ), I then call the method within my method prop_add() in the controller like this: $this-Admin-setValidation('prop_add'); Any ideas? On Jun 17, 11:06 am, koala kid [EMAIL PROTECTED] wrote: Hi, thanks for your help, its really appreciated. I'm new to cake and although I know its going to be beneficial in the long run right now the learning curve sucks and what really makes it worse is the lack of decent documentation. For example the behaviour you gave me the link to seems to do exactly what I need but it doesn't tell me where to save it and what to call the file. Can you explain? Thanks. On Jun 17, 6:03 am, keymaster [EMAIL PROTECTED] wrote: How do I run cake's validation methods on each form separately. At the moment you appear to define your rules in $validate outside of any functions/methods. How do I run it from within a method. Use this behavior: http://bakery.cakephp.org/articles/view/using-many-validation-ruleset... --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Form validation - multiple forms and multiple tables used per model
Hi, I am using one model to process and save the data for multiple forms. How do I run cake's validation methods on each form separately. At the moment you appear to define your rules in $validate outside of any functions/methods. How do I run it from within a method. In addition as my model saves to multiple tables I am not using $this- save(). How do I enforce validation without using this method? Thanks for any help. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Ajax form submission
I am new to cake and have just built my first site using it. To spice it up I wanted to add a newsletter sign-up form on the home page that uses Ajax to both submit the email address and provide a response. However the documentation appears to be lacking and I can't find a good example anywhere of how to do this. Could someone provide any pointers on: What a controller would look like What components I need to include What a view would like like Can I perform validation on the email What a model may look like. Thanks in advance for any help I get. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Routing issue
I am having an issue with the routing with a new site I have just launched http://www.naturalswingolf.com/. Following any link will only display the home page. I have reviewed my routes.php and everything seems in order. Can anyone spot a problem with it: $Route-connect('/', array('controller' = 'pages', 'action' = 'display', 'home')); $Route-connect('/pages/*', array('controller' = 'pages', 'action' = 'display')); $Route-connect ('/testimonials/:action/*', array('controller'='testimonials', 'action'='index')); 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 -~--~~~~--~~--~--~---
Path issue passing data to Flash movie
Hi all, I have multiple pages on a site I am developing that use a Flash gallery viewer application. The movie receives a parameter via FlashVars with the path to the specific gallery xml file listing all the images to load. However as soon as I navigate away from the home page the xml file fails to load. I am new to cake and have no idea what is causing the problem. You can compare these two pages which both use the same path, same xml file: http://www.globehomesandcondos.com/ http://www.globehomesandcondos.com/props/ Any help would be greatly appreciated. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Newbie problem, reading id passed in URL
Hi All, this is my first application using cakePHP so apologies if this is a bit basic. I was following the 15min blog tutorial and using it as the basis for my own application but I am getting an error when I try and pass through an ID to a function via the URL. e.g. http://localhost/nsg/testimonials/deActivate/5 should be calling the function deActivate ($id) in the testimonials_controller.php but I keep getting the error: You are seeing this error because the view for PagesController::testimonials/deActivate/5() could not be found. If you want to customize this error message, create app\views/errors/ missing_view.thtml. Fatal: Confirm you have created the file : C:\xampp\htdocs\nsg\app \views\pages\testimonials/de_activate/5.thtml I have had to configure routes.php to get my application working so I am unsure if this is the problem area but other functions in the controller that do not require an ID all perform fine. My routes looks like: $Route-connect ('/testimonials', array('controller'='testimonials', 'action'='index','index')); $Route-connect ('/testimonials/view', array('controller'='testimonials', 'action'='view','view')); $Route-connect ('/testimonials/add', array('controller'='testimonials', 'action'='add','add')); $Route-connect ('/testimonials/listActive', array('controller'='testimonials', 'action'='listActive','list_active')); $Route-connect ('/testimonials/listUnActive', array('controller'='testimonials', 'action'='listUnActive','list_unactive')); $Route-connect ('/testimonials/update/', array('controller'='testimonials', 'action'='update','index')); $Route-connect ('/testimonials/delete/', array('controller'='testimonials', 'action'='delete','index')); Any help would be appreciated. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---