我想要这些行运行FOR我的数据库的所有值 [英] I want these lines to run FOR ALL of the values of my database

查看:149
本文介绍了我想要这些行运行FOR我的数据库的所有值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 $sql = 'SELECT * FROM t1
         RIGHT OUTER JOIN t2 ON t2.wid = t1.wid
         LIMIT ' . $number . ' OFFSET 678';

当我改变我的手这个偏移量运行不同的数据库的值...如何可以做到没有改变用我的手这个偏移?有人说我,我可以做到没有胶印,但他没有告诉我怎么...有人可以帮助plz?我有一个月有这个问题:'(:'(:'(

When i change by my hand this offset it runs for different values of my database... How I can do it without change with my hand this offset?? Someone said me that I can do it without offset but he did not tell me how... Could someone help plz?? I have over a month with this issue :'( :'( :'(

推荐答案

$per_page = 10;
$current_page = read_current_page(); // 0,1,2...
$start = $current_page*$per_page;

 $sql = 'SELECT * FROM t1
         RIGHT OUTER JOIN t2 ON t2.wid = t1.wid
         LIMIT ' . $start . ','. $per_page;
save_current_page(++$current_page);

这应该是这样的。read_current_page()应该从文件,数据库或其他地方读取值

It should be something like that. read_current_page() should somehow read value from file, database or where ever you decide to keep that value. So, you need some place to store it between the calls.

然后你创建你的查询,最后你必须更新价值。添加一些逻辑来重置它,你需要它的方式,但点是你必须存储在代码之外的地方...因为调用后执行所有的值都会丢失。

Then you create your query and at end you have to update value of that counter. Add also some logic to reset it, the way you need it. But point is that you have to store it somewhere outside of your code...since after call is executed all values are lost.

这篇关于我想要这些行运行FOR我的数据库的所有值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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