Wednesday, March 31, 2010

$this->...->query("...");

Hey everyone,

i tried to make an join query on two tables!

my query is:

SELECT *
FROM planets AS Planet
LEFT OUTER JOIN buildings AS Building ON (Planet.id =
Building.planet_id)
WHERE Building.user_id=1;

so, the query works well in my PMA and in Workbench (CL),
but in cakePHP it makes some additional querys:

SELECT COUNT(*) AS `count`
FROM `planets` AS `Planet`
WHERE ((Planet IN ('1', 'Planet Erde', '100', '1', '100', '10', '10',
'10', '[1,20,20]', '400'))
AND (Building IN ('1', '1', '1', 'command_center', '1', '[25,25]')))
AND ((Planet IN ('2', 'Mond', '100', '0', '100', '0', '10', '-5',
'[1,21,20]', '100'))
AND (Building IN ('3', '2', '1', 'explorer_small', '2', '[10,4]')))

SELECT `Planet`.`id`, `Planet`.`name`, `Planet`.`space`,
`Planet`.`space_used`, `Planet`.`healthpoints`, `Planet`.`oil`,
`Planet`.`water`, `Planet`.`heat`, `Planet`.`coordinates`,
`Planet`.`size`
FROM `planets` AS `Planet`
WHERE ((Planet IN ('1', 'Planet Erde', '100', '1', '100', '10', '10',
'10', '[1,20,20]', '400'))
AND (Building IN ('1', '1', '1', 'command_center', '1', '[25,25]')))
AND ((Planet IN ('2', 'Mond', '100', '0', '100', '0', '10', '-5',
'[1,21,20]', '100'))
AND (Building IN ('3', '2', '1', 'explorer_small', '2', '[10,4]')))
LIMIT 20

This doesn relly can work because of: Planet IN ('1', 'Planet Erde',
'100', '1', '100'.. doesn't really make sense; ey?
Why does cakePHP do that?

greets from Vienna
Dom

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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

To unsubscribe, reply using "remove me" as the subject.

No comments: