find('first') query cakephp1.2 vs 1.3
I'm porting my app from cakephp 1.2 to 1.3 and followed all steps in the migration guide. Still having troubles with find queries. I have quite some queries doing: $this-User-id = 4; $data = $this-User-find('first'); Cake 1.2 builds the following query: SELECT `User`.`id`, FROM `users` AS `User` WHERE `User`.`id` = 4 ORDER BY `name` ASC LIMIT 1 Cake 1.3.1 builds a different query: SELECT `User`.`id`, FROM `users` AS `User` WHERE 1 = 1 ORDER BY `name` ASC LIMIT 1 I just get the first record, but not the one that matches the set id. I like the short and readable notation of this query. Is this a wrong way of retreiving model data? Should I go for the long notation (including the conditions option that tells find to search for User.id = 4) ?? Or is it a cake bug? Bests, Bram 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: find('first') query cakephp1.2 vs 1.3
$data = $this-User-read(null, 4); that is the official way to get one row.. another possible ways: $this-User-findById(4); $this-User-find('first', array('conditions' = array('User.id' = 4))) bye, gonzalo On 2 jun, 09:09, bram brammele...@gmail.com wrote: I'm porting my app from cakephp 1.2 to 1.3 and followed all steps in the migration guide. Still having troubles with find queries. I have quite some queries doing: $this-User-id = 4; $data = $this-User-find('first'); Cake 1.2 builds the following query: SELECT `User`.`id`, FROM `users` AS `User` WHERE `User`.`id` = 4 ORDER BY `name` ASC LIMIT 1 Cake 1.3.1 builds a different query: SELECT `User`.`id`, FROM `users` AS `User` WHERE 1 = 1 ORDER BY `name` ASC LIMIT 1 I just get the first record, but not the one that matches the set id. I like the short and readable notation of this query. Is this a wrong way of retreiving model data? Should I go for the long notation (including the conditions option that tells find to search for User.id = 4) ?? Or is it a cake bug? Bests, Bram 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: find('first') query cakephp1.2 vs 1.3
The migration guide actually mentions this change in paragraph 11.1.2: Model::find(first) will no longer use the id property for default conditions if no conditions are supplied and id is not empty. Instead no conditions will be used 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: find('first') query cakephp1.2 vs 1.3
use $this-User-find('first', array('conditions' = array('User.id' =4))) everything else is either deprecated or used for something else On 2 Jun., 17:39, bram brammele...@gmail.com wrote: The migration guide actually mentions this change in paragraph 11.1.2: Model::find(first) will no longer use the id property for default conditions if no conditions are supplied and id is not empty. Instead no conditions will be used 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