关于ThinkPHP删除数据库记录的奇怪问题

WBOY
Release: 2016-06-23 14:38:15
Original
856 people have browsed it

我使用

M('data')->where('user=xiaoming')->delete();
Copy after login
删除数据库中data表中user为xiaoming的一条记录,但是我发现这条语句没有执行,删不了。可是我如果将用户名user改成数字的话,这条记录却是可以执行删除的,这是怎么回事呢,好奇怪。

如果直接在mysql里面输入delete语句的话,不管user是数字还是字母都可以删除


回复讨论(解决方案)

把xiaoming用单引号引起来, user='xiaoming'

搞定了,用

 M('data')->where(array('user'=>'qiguai'))->delete();
Copy after login
或者
 M('data')->where("user='xiaoming'")->delete();
Copy after login
都可以

source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template