如何在kohana中优化子查询

时间:2014-03-05 07:37:03

标签: php mysql kohana kohana-3 kohana-orm

models.php

     ->add_subquery('(SELECT character_name FROM zid_character_details WHERE character_detail_id = (SELECT character_detail_id from zid_guild_feeds where feed_id = feeds.guild_parent_feed_id)) AS guildcharacter')
     ->add_subquery('(SELECT character_detail_id FROM zid_character_details WHERE character_detail_id = (SELECT character_detail_id from zid_guild_feeds where feed_id = feeds.guild_parent_feed_id)) AS guildcharacter_id')
     ->add_subquery('(SELECT character_icon FROM zid_character_details WHERE character_detail_id = (SELECT character_detail_id from zid_guild_feeds where feed_id = feeds.guild_parent_feed_id)) AS guildcharacter_icon')

以上是我使用的三个子查询character_namecharacter_detail_id&来自character_icon表的zid_character_details,参考zid_guild_feeds表。

任何人都可以告诉我如何将这三个查询优化为单个或简单的查询。

由于

1 个答案:

答案 0 :(得分:0)

查看Kohana Query Builder JoinsKohana Query Builder Subqueries

当您需要探索各种ORM时,我建议您查看Leap ORM