[英]How to retrieve query stored in session in codeigniter?
while using codeigniter i have saved current query in session so that I can show pagination in detail page means prev/next button detail screen.But when I use LIKE %10% in query it shows in home page that its stored in session but when I go to detail page its not in the session.Any guess I am not storing session in database as documented in user guide 当我使用codeigniter时,我已经在会话中保存了当前查询,以便我可以在详细页面中显示分页意味着prev / next按钮详细信息屏幕。但是当我在查询中使用LIKE%10%时,它将在主页中显示其存储在会话中,但是当我转到详细信息页面它不在会话中。任何猜测我都没有按照用户指南中的说明将会话存储在数据库中
my query is simple 我的查询很简单
SELECT Contac.cm_id
FROM Contact
LEFT JOIN Employer
ON (Contact.c_id = Employer.ei_contact_id)
AND (Employer.ei_primary_employer = "Y")
WHERE ( Contact.cm_staff_name LIKE '%s%'
AND Contact.cm_staff_name NOT LIKE 'NULL' )
ORDER BY Contact.cm_id ASC
so when there is 03 in Contact.cm_staff_name LIKE '%03%'
its not passing that query from one page to another through session . 因此,如果
Contact.cm_staff_name LIKE '%03%'
存在03,则不会通过session将查询从一页传递到另一页。 Also please suggest if better solution instead of using session. 另外,请提出更好的解决方案,而不是使用会话。 Any guess
任何猜测
There is no point in storing a program anywhere. 将程序存储在任何地方都没有意义。
A program have to be written in a constant form and fed with dynamical variables . 程序必须以常量形式编写,并应包含动态变量 。
Using sessions for pagination is also wrong idea - look at google for example - they always use a query string to pass variables for the next page. 使用会话进行分页也是一个错误的想法-例如,以google为例-他们总是使用查询字符串来传递下一页的变量。 It will let a user to bookmark certain page or send it to a friend or whatever.
它将允许用户为特定页面添加书签或将其发送给朋友或其他任何人。 It is always a pain when a friend sends you a link but you have no their session and cannot see what they see.
当朋友向您发送链接但您没有他们的会话并且看不到他们看到的内容时, 总是很痛苦 。
So, write your query right in the code 因此,直接在代码中编写查询
pass all the variables via GET query string 通过GET查询字符串传递所有变量
and use prepared statements to insert variables into query 并使用准备好的语句将变量插入查询
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.