最后几天,我在玩CI的分页。我已经设置了config,它工作得很好。在控制器的功能中,我创建了一些IF语句来检查url。
IF url is localhost/CI/index.php/controller/function/news
THEN return first page of results from database -> first page
BUT IF url is localhost/CI/index.php/controller/function/news/10
THEN return second page of results from database -&
当我检查此url页面分页时,分页工作正常,并在页面和page=+1中显示页面结果:
mydomain/search.php?page=1
mydomain/search.php?page=2
但当我查到这个网址时:
mydomain/search.php?page=-1
mydomain/search.php?page=-2
我看到这个错误:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to
我正在使用Codeignit2.2,我试图构建分页,询问Codeigniter指南,当我使用下面的url时,它非常适合我。
$pages_num: is the amount of pages for view.
http://localhost/Codeigniter2.1.4/public_html/page/$pages_num
但是当我为url添加一个参数作为下面的代码时,我在3周前试图找到它,但我没有解决问题,请注意:第2号是id类别,第4个是分页视图的数量。
http://localhost/Codeigniter2.1.4/public_html/cat/2/4
这是我在控制器中
我认为每个人(大多是CI用户的初学者)在使用有活动记录的分页方面都会遇到困难。
在CI的正式文档中,没有明确的说明如何在活动记录中使用分页类对象。我的问题是;无法定义当前页并将其设置为SQL语句。因此,当程序以分页方式从MySQL获取数据时,所有页面首先导航0和$config['per_page'];。我的意思是,如果我设置为per_page=20,那么所有页面链接的取0,20行MySQL行。
我的SQL语句是:
$this->db->query("SELECT b.*, a.adCampaignTitle FROM ads a, sms b WHERE b
我需要添加分页到我的网页表单(目前,我已经从数据库返回所有,但现在有太多)。
result = []
session = Session()
index = 1
for user in session.query(UserModel).order_by(desc(UserModel.age)).all():
result.append({'username' : user.username,
'nation' : user.nation,