-
-
Save AD7six/e84aa17eaa02f77ab79f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$posts = $this->Post->find('all', array( | |
'contain' => array( | |
'Comment' => array( | |
'Commenter' | |
), | |
) | |
)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 SELECT `Post`.`id`, `Post`.`user_id`, `Post`.`title`, `Post`.`body`, `Post`.`published`, `Post`.`allow_comments`, `Post`.`created` FROM `test_database_name`.`posts` AS `Post` WHERE 1 = 1 5 5 0 | |
2 SELECT `Comment`.`id`, `Comment`.`post_id`, `Comment`.`user_id`, `Comment`.`comment`, `Comment`.`created` FROM `test_database_name`.`comments` AS `Comment` WHERE `Comment`.`post_id` IN (1, 2, 3, 4, 5) 3 3 1 | |
3 SELECT `Commenter`.`id`, `Commenter`.`name`, `Commenter`.`bio`, `Commenter`.`created` FROM `test_database_name`.`users` AS `Commenter` WHERE `Commenter`.`id` = 1 1 1 0 | |
4 SELECT `Commenter`.`id`, `Commenter`.`name`, `Commenter`.`bio`, `Commenter`.`created` FROM `test_database_name`.`users` AS `Commenter` WHERE `Commenter`.`id` = 2 1 1 0 | |
5 SELECT `Commenter`.`id`, `Commenter`.`name`, `Commenter`.`bio`, `Commenter`.`created` FROM `test_database_name`.`users` AS `Commenter` WHERE `Commenter`.`id` = 1 1 1 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
5 posts, and 3 comments = 5 queries
100 posts and 3 comments = 5 queries
5 posts and 100 comments = 102 queries.