多个子查询的php限制偏移量分布
我有以下代码来获取通知项列表:多个子查询的php限制偏移量分布,php,mysql,algorithm,sorting,activerecord,Php,Mysql,Algorithm,Sorting,Activerecord,我有以下代码来获取通知项列表: public function actionMynotifications($offset,$auth_key) { $limit = intval(1); while ($limit >= intval(5)) { // } $this->findA($offset,$limit,$userid); $this->findB($offset,$limit,$userid); $this->findC($offset,
public function actionMynotifications($offset,$auth_key)
{
$limit = intval(1);
while ($limit >= intval(5)) {
//
}
$this->findA($offset,$limit,$userid);
$this->findB($offset,$limit,$userid);
$this->findC($offset,$limit,$userid);
$this->findD($offset,$limit,$userid);
$this->findE($offset,$limit,$userid);
作为输入,通过增加$offset
对其进行Url查询。作为一个限制,我想要5个。但这是一个不同类型的列表,当它是作为数组返回的一个结果时,应按我在输入的创建的(u)进行排序:
$this->findA($offset,$limit,$userid)['created_at'];
我的想法是比较所有路线,找到在创建的“最新”,并重复此操作,直到我在$offset
0上有一个5(限制)的列表
我的问题是,我不知道性能比较循环从何处开始,该循环不会产生许多if-else语句$抵销和$limit必须对结果保持一致,例如,因为不清楚最年轻的项目在哪里
(偏移量=0/极限值=5)
A.
A.
A.
B
E
或(偏移量=5/极限值=5)
A.
A.
A.
B
E
A
C
D
A.
B
我很乐意在需要的时候提供更多的信息,只是评论一下
或者为每个用户设置一个额外的表,其中包含在
处创建的,类型
(对于表),id
,并按间隔完全重新排序以提供此功能,这是否更智能
或者把它放在缓存中的最后一个。并对此提出质疑