0

I have 7 queries different and I use this code for merge query and sort query:

$array= array_merge($aPhotos, $aVideos, $aMusics, $aSongs, $aBlogs, $aPolls, $aQuizzes);

foreach ($arry as $k => $v) {   
 $sort[$k] = $v[$sortNode];
}

array_multisort($sort, SORT_DESC, $array);

Now I want create paginator for final array $array

I use on each query the same LIMIT, example LIMIT 0, 10

Sometimes the query return 7 rows, other 10 rows, or 0 rows.

Each query return different number of query.

All work fine with my paginator when the query returned is 70 (7*10)

Paginator don't work when rows is different.

My question is how to create a paginator in this case.

The best solution is use UNION!

4

1 回答 1

1

我从不尝试对多个查询进行分页。我知道 7 个查询很多,但我认为花点时间弄清楚如何将它们组合成一个查询是值得的。MySQL 有一些强大的功能,根据我的经验,我经常对我可以通过单个查询完成的事情感到惊讶。

于 2012-08-30T21:43:58.493 回答