Re: model::query different output with different version of php - a bug or?
Your SQL didn't work , but I changed it a bit and this gives the same output on both machines: 'SELECT `Chassis`.`equipment_id` FROM (select `Chassis`.`equipment_id` from chassis as `Chassis` group by `Chassis`.`equipment_id` LIMIT 3) as Chassis' Note that the alias on the table in subquery is the same as the alias for the whole subquery... It looks like SQL soup..but it solves the problem... Otherwise if aliases are different, I get different names for output array keys On Mar 21, 4:14 am, "wralph" <[EMAIL PROTECTED]> wrote: > I always make it a habit of explicitly stating the alias in all my > queries like so: > > SELECT `Chassis`.`a.equipment_id` FROM (select > `Chassis`.`equipment_id` from chassis as `Chassis` group by > `Chassis`.`equipment_id` LIMIT 3); > > Which should give you an array like no matter which mysql/PHP version > you use: > Array > ( > [0] => Array > ( > [Chassis] => Array > ( > [equipment_id] => 1 > ) > > ) > ) > > Winston --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: model::query different output with different version of php - a bug or?
I always make it a habit of explicitly stating the alias in all my queries like so: SELECT `Chassis`.`a.equipment_id` FROM (select `Chassis`.`equipment_id` from chassis as `Chassis` group by `Chassis`.`equipment_id` LIMIT 3); Which should give you an array like no matter which mysql/PHP version you use: Array ( [0] => Array ( [Chassis] => Array ( [equipment_id] => 1 ) ) ) Winston --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: model::query different output with different version of php - a bug or?
Yes, it's an unfortunate side effect of using custom queries, especially when joins or nested queries are involved. For a project, I modified the core to use "0" as the alias if the table name returned didn't match a list of model names. In the database.php file, I declared a list of all available model names. This ensured consistent naming on output. On Mar 20, 7:30 am, "sawa" <[EMAIL PROTECTED]> wrote: > Yes, probably different php-mysql library or something similar..but > it's really annoying --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: model::query different output with different version of php - a bug or?
Yes, probably different php-mysql library or something similar..but it's really annoying --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: model::query different output with different version of php - a bug or?
Hello, I think this is the different mysql version problem. sawa írta: > Hi, > I have 2 installations of cakePHP on 2 servers. > Both cakePHP versions are 1.1.13.4450 > Both PHP were Version 5.2.0. > Then one is updated to PHP Version 5.2.0-8+etch1. > After the update, custom queries which have subqueries started giving > different output. > > Here is the example: > > PHP Version 5.2.0 > > pr($this->Application->query('SELECT a.equipment_id FROM (select > equipment_id from chassis group by equipment_id LIMIT 3) as a')); > > gives: > > Array > ( > [0] => Array > ( > [chassis] => Array > ( > [equipment_id] => 1 > ) > > ) > > [1] => Array > ( > [chassis] => Array > ( > [equipment_id] => 2 > ) > > ) > > [2] => Array > ( > [chassis] => Array > ( > [equipment_id] => 3 > ) > > ) > > ) > > PHP Version 5.2.0-8+etch1. > > gives: > > ( > [0] => Array > ( > [a] => Array > ( > [equipment_id] => 1 > ) > > ) > > [1] => Array > ( > [a] => Array > ( > [equipment_id] => 2 > ) > > ) > > [2] => Array > ( > [a] => Array > ( > [equipment_id] => 3 > ) > > ) > > ) > > As you can see, in second result, table name is replaced with alias > name. > > I'm not sure if this is a bug or what, but I wonder how to get the > same output on both platforms > > > > > -- Ámon Tamás http://linkfelho.amon.hu --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: model::query different output with different version of php - a bug or?
Oh, one more clarification: The query above is just illustration of what happens. The real query I use is more complicated (more subqueries included) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
model::query different output with different version of php - a bug or?
Hi, I have 2 installations of cakePHP on 2 servers. Both cakePHP versions are 1.1.13.4450 Both PHP were Version 5.2.0. Then one is updated to PHP Version 5.2.0-8+etch1. After the update, custom queries which have subqueries started giving different output. Here is the example: PHP Version 5.2.0 pr($this->Application->query('SELECT a.equipment_id FROM (select equipment_id from chassis group by equipment_id LIMIT 3) as a')); gives: Array ( [0] => Array ( [chassis] => Array ( [equipment_id] => 1 ) ) [1] => Array ( [chassis] => Array ( [equipment_id] => 2 ) ) [2] => Array ( [chassis] => Array ( [equipment_id] => 3 ) ) ) PHP Version 5.2.0-8+etch1. gives: ( [0] => Array ( [a] => Array ( [equipment_id] => 1 ) ) [1] => Array ( [a] => Array ( [equipment_id] => 2 ) ) [2] => Array ( [a] => Array ( [equipment_id] => 3 ) ) ) As you can see, in second result, table name is replaced with alias name. I'm not sure if this is a bug or what, but I wonder how to get the same output on both platforms --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---