`Books__price`, Books.author_id AS `Books__author_id`, Authors.id AS `Authors__id`, Authors.name AS `Authors__name`, Authors.has_copyright AS `Authors__has_copyright` FROM books Books LEFT JOIN authors Authors ON Authors.id = (Books.author_id) WHERE Books.id = 1 LIMIT 1
$author; /** * @ORM\ManyToOne(targetEntity="Author", inversedBy="books", fetch="EAGER") * @ORM\JoinColumn(name="author_id", referencedColumnName="id") */ private $author; SELECT t0.id AS id_1, t0.title AS title_2, t0.price AS price_3, t0.author_id AS author_id_4 FROM books t0 WHERE t0.id = 1; SELECT t0.id AS id_1, t0.name AS name_2, t0.has_copyright AS has_copyright_3 FROM authors t0 WHERE t0.id = 1; SELECT t0.id AS id_1, t0.title AS title_2, t0.price AS price_3, t0.author_id AS author_id_4, t5.id AS id_6, t5.name AS name_7, t5.has_copyright AS has_copyright_8 FROM books t0 LEFT JOIN authors t5 ON t0.author_id = t5.id WHERE t0.id = 1;
$book->author->name; } select * from `books` select * from `authors` where `authors`.`id` in (1, 2, 3, 4) $books = Book::get(); foreach ($books as $book) { echo $book->author->name; } select * from `books` select * from `authors` where `authors`.`id` = 1 select * from `authors` where `authors`.`id` = 1 select * from `authors` where `authors`.`id` = 1 select * from `authors` where `authors`.`id` = 2 … ͜Ε͕ books ͷ͚ͩൃੜ