开发者

Join 3 tables using Doctrine_RawSql object

开发者 https://www.devze.com 2023-02-15 02:14 出处:网络
Is there any way to make this select: SELECT * FROM `sf_guard_user` JOIN `friendship` ON `friendship`.`user_id` = `sf_guard_user`.`id`

Is there any way to make this select:

SELECT * 
FROM `sf_guard_user` 
JOIN `friendship` 
  ON `friendship`.`user_id` = `sf_guard_user`.`id` 
JOIN `circle` 
  ON `friendship`.`circle_id` = `circle`.`id` 
WHERE `circle`.`id` = 1 
ORDER BY `circle`.`id`

with a Doctrine_RawSql o开发者_运维技巧bject without using foreign keys?


Why did you decide to use Doctrine_RawSql?

In this example, I'm using inner join:

SELECT sf.* FROM `sf_guard_user` sf
INNER JOIN `friendship` f on  f.`user_id` = sf.`id` 
INNER JOIN `circle` c on f.`circle_id` = c.`id` 
WHERE c.`id` = 1 
ORDER BY c.`id`
0

精彩评论

暂无评论...
验证码 换一张
取 消