i was wondering why the containable beh. as well as many other queries
are done in that very complicated way of
- getting the results of the first table
- use these ids for the result of the other tables with IN(x,y,z,...)
instead of just using LEFT JOIN?
it really gave me headache yesterday trying to use containable on
"users" -> HAS MANY -> "phone_numbers" <- HAS MANY <-"numbers"
besides the fact that i did not get the inner join to work here, my
actual problem is the following:
either way (from users down to numbers, or the other way around), it
resulted in over 1200 queries (!!!) crashing my apache and database or
resulting in an execution timeout error.
well, there are around 2000 entries - but after setting up a manual
query like this:
"Select User.id, User.first_name, User.middle_name, User.last_name,
Number.prefix, Number.number
FROM numbers AS `Number`
INNER JOIN phone_numbers AS `PhoneNumber` ON (Number.id
=
PhoneNumber.number_id)
INNER JOIN users AS `User` ON (User.id =
PhoneNumber.user_id)"
i ended up in 1/10000 of time needed for the cake'sh way, with the
exact result i expected.
is there a way to accomplish something similar using the behaviour?
usually left joins always execute hundred times faster then the
cakeish way described above (especially if the tables get fuller and
fuller)
the result with my custom query now was:
Array
(
[0] => Array
(
[User] => Array
(
[first_name] => test
[last_name] => user
)
[Number] => Array
(
[prefix] => 123
[number] => 123456
)
)
...
)
and if several users shared the same number, or a user had several
numbers they would (as an inner join would do) result in seperate
entries
thx :)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---