如何在Codeigniter中向联合表添加分页 [英] How to add pagination to union tables in codeigniter

查看:98
本文介绍了如何在Codeigniter中向联合表添加分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将分页添加到unionTable?

How to add pagination to unionTable?

通常我做这样的事情:

    $query = $this->db->get('tutorial', $num, $offset);

但是我不知道该怎么做.

but i don`t know how to do it here help.

    $query = $this->db->query("SELECT * FROM
             ($subQuery1 UNION $subQuery2 UNION $subQuery3)
             AS unionTable GROUP BY date DESC");

推荐答案

如果您使用的是Mysql,请尝试以下代码:

if you are using Mysql, try the following code:

$query = $this->db->query("SELECT * FROM
         ($subQuery1 UNION $subQuery2 UNION $subQuery3)
         AS unionTable GROUP BY date DESC LIMIT $num, $offset");

注意:请确保在查询之前为变量$ num和$ offset设置了正确的值.

NOTICE: make sure that you have set the correct values to the variables $num and $offset before query.

这篇关于如何在Codeigniter中向联合表添加分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆