您好,欢迎访问一九零五行业门户网

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
不谢。
其它类似信息

推荐信息