TP框架的这句话哪里不对?
$info=M("qq")->where('name like','$name%')->select();
where里面是不是写的不对?给如下的错误提示: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 ')' at line 1 [ SQL语句 ] : SELECT * FROM qq
WHERE ( name like )
如果按百度出来的like的例子username like 'Admin%' 这样写的话
$info=M("qq")->where(name like '$name%')->select();
也是会报错:syntax error, unexpected 'like' (T_STRING)
回复内容:
$info=M("qq")->where('name like','$name%')->select();
where里面是不是写的不对?给如下的错误提示: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 ')' at line 1 [ SQL语句 ] : SELECT * FROM qq
WHERE ( name like )
如果按百度出来的like的例子username like 'Admin%' 这样写的话
$info=M("qq")->where(name like '$name%')->select();
也是会报错:syntax error, unexpected 'like' (T_STRING)
$info=M("qq")->where("name like '%s'",array($name))->select();
有时间可以看下 where方法的源码 或 看下pdo参数绑定 会有很大帮助
//试试用这段代码:
M('qq')->where(['name'=>['LIKE',"$name%"])->select();
见tp文档:http://www.kancloud.cn/manual/thinkphp/1768
不谢。