1
显然,活动记录不能处理临时表 - 在我看来,巨大的监督。 (参考:Codeigniter 2 active record — How do I create temporary table to apply second sort order?)笨 - 我该如何排序我的数据库结果对象(排序PHP对象)
在此我要寻找一种方式来排序我的查询产生的结果对象光。
这里是我的查询:
$this->db
->select('*')
->from('item_categories')
->where('item_categories.cat_id', $c)
->or_where('item_categories.parent_id', $c)
->or_where('item_categories.gparent_id', $c)
->join('item_categories_rel', 'item_categories_rel.cat_id = item_categories.cat_id', 'right')
->join('item_entries', 'item_entries.item_id = item_categories_rel.item_id','right')
->join('ratings_total', 'ratings_total.item_id = item_entries.item_id')
->order_by("item_name", "asc")
->limit($l, $s);
$result = $this->db->get();
因此,例如,我的结果中包含一个域名为site_rating它的类型是小数(2,1)的,我怎么能在递增/递减排序site_rating我结果对象订购?任何帮助不胜感激。
要清楚我不想更改当前的顺序,我想对第一个结果集应用第二个排序顺序 - 我发现我无法对活动记录执行此操作,因此想要通过排序如果可能,结果对象。
对不起,我可能不会一直在清楚我的问题。我需要将它们按原样排序,然后我需要应用第二种排序。因此,例如我原来的查询获取前50个结果按照项目名称,然后我想通过自己的评价这些结果 – WebweaverD
你能用几个项目上的SQL小提琴为例数据库进行排序,那么我们就可以用你的数据库播放给你是正确的结果。 – Tschallacka
从来没有听说过的SQL拨弄之前....我会做到这一点,后回 – WebweaverD