public function getAllCelebDataFinal ($database,$celebrityId,$lastOutputId)
{
$getalldata = $database->executeObjectList("
SELECT *
FROM (
(SELECT v.vidId, NULL as newsId, NULL as photoId, NULL as imageFile,
v.title as vidTitle, NULL as newsTitle, v.videoLink AS vidLink,
NULL as newsVidLink, NULL as newDetail , v.addDate
FROM videos v
WHERE v.celebrityId='".$celebrityId."' AND v.isPublished=1)
UNION ALL
(SELECT NULL as vidId, n.newsId,NULL as photoId,NULL as imageFile,
NULL as vidTitle, n.title as newsTitle, NULL AS vidLink,
n.videoLink as newsVidLink, n.details as newDetail,
n.addDate
FROM news n
WHERE n.celebrityId='".$celebrityId."' AND n.isPublished=1)
UNION ALL
(SELECT NULL as vidId,NULL as newsId,p.photoId,p.imageFile,
NULL as vidTitle, NULL as newsTitle, NULL AS vidLink,
NULL as newsVidLink, NULL as newDetail , p.addDate
FROM photos p
WHERE p.celebrityId='".$celebrityId."' AND p.isPublished=1)
) results
ORDER BY addDate DESC
LIMIT 5");
return $getalldata;
}
Consider it as a second query, if i am running first query with the limit 5, i am sendind 5 as $lastOutputId as a parameter, and i want to run this query as 5 to 5+5, and in the same way, next query would run with limit 10 to 15. How can i do that?
解决方案
LIMIT may have 2 parameters. In our case I think you can use LIMIT like this:
LIMIT $lastOutputId, 5