PHP速学视频免费教程(入门到精通)
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
想要查找uid倒数第二位的数值一样的数据
比如
1000000005
1000000006
1000000007
1000000008
1000000023 //不同的不要
1000000009
要实现这样的逻辑,怎么办
<code>$uid = I('get.uid', 0, 'intval');//假设用户ID:1000000005 $where['uid'] = substr($uid, -2,1);//倒数第二位:0 $res = M('code')->where($where)->select();//这样做实现不了</code>
想要查找uid倒数第二位的数值一样的数据
比如
1000000005
1000000006
1000000007
1000000008
1000000023 //不同的不要
1000000009
要实现这样的逻辑,怎么办
<code>$uid = I('get.uid', 0, 'intval');//假设用户ID:1000000005 $where['uid'] = substr($uid, -2,1);//倒数第二位:0 $res = M('code')->where($where)->select();//这样做实现不了</code>
<code>$where['uid'] = 'substr('+$uid+', -2,1)'; </code>
加上引号试一下,不加引号变成php中的函数了,mysql 也有substr函数的
你要生成的是类似这样的语句
<code>select * from `character` where SUBSTR(characterId, -2, 1) ='1'</code>
已抢6799个
抢已抢91611个
抢已抢14418个
抢已抢50597个
抢已抢190557个
抢已抢86252个
抢