workman里封装的数据库方法,where 可以直接用in方法吗。我用了,它报错。Parse error: syntax error, unexpected 'restart' (T_STRING) in /pi/components/com_work/GatewayWorker/Lib/Gateway.php on line 134
有谁具体用过。具体代码
public static function getInsertUsers($user,$count){//返回需要增加的用户列表
$redis = new \Redis();
$redis->connect('127.0.0.1', 6379);
$key = 'maxcont:' .$user;
$c= $redis ->llen($key)-$count;
$rr= $redis -> lRange($key, 0, (int)($c));php /pi/components/com_work/start.php restart
$r= implode(',', $rr);
$db1 = Db::instance('db1');
if( !empty($r) ){
return $db1->select('userid,alias,thumb,latitude,longitude')->from('q_community_users')->where('userid in $r')->query();
}
}
exception 'PDOException' with message 'SQLSTATE: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '$r' at line 1' in /pi/components/com_work/GatewayWorker/Lib/DbConnection.php:1751
是PHP语法错误啊,自己的问题啊,和workerman数据库类没毛关系。
第二个sql语法错误啊,又是你自己的问题啊
where('userid in $r')
改成
where("userid in ($r)")
试下。php变量放到双引号里才能解析啊,而且你好像还少了个括号。
上面的说法很中肯,也很真实,我也改过来了。尝试in的各种写法,现在还是报错
报错信息
exception 'PDOException' with message 'SQLSTATE: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'in( '422,421,421,420,419,418,417,416,415')' at line 1' in /pi/components/com_work/GatewayWorker/Lib/DbConnection.php:1751 Stack trace:
终于不报错了