Home > Backend Development > PHP Tutorial > What's wrong with this sentence of the TP framework?

What's wrong with this sentence of the TP framework?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-06 13:53:28
Original
1246 people have browsed it

<code>$info=M("qq")->where('name like','$name%')->select();</code>
Copy after login
Copy after login

Is it written incorrectly in where? Give the following error message: 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 statement]: SELECT * FROM qq WHERE ( name like )

If you write the like example username like 'Admin%' from Baidu like this
$info=M("qq")->where(name like '$name%')->select( );
will also report an error: syntax error, unexpected 'like' (T_STRING)

Reply content:

<code>$info=M("qq")->where('name like','$name%')->select();</code>
Copy after login
Copy after login

Is it written incorrectly in where? Give the following error message: 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 statement]: SELECT * FROM qq WHERE ( name like )

If you write the like example username like 'Admin%' from Baidu like this
$info=M("qq")->where(name like '$name%')->select( );
will also report an error: syntax error, unexpected 'like' (T_STRING)

<code>$info=M("qq")->where("name like '%s'",array($name))->select();</code>
Copy after login

If you have time, you can look at the source code of the where method or look at the pdo parameter binding, it will be of great help

<code>//试试用这段代码:

M('qq')->where(['name'=>['LIKE',"$name%"])->select();</code>
Copy after login

See tp documentation: http://www.kancloud.cn/manual/thinkphp/1768

You’re welcome.

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template