Home >Backend Development >PHP Tutorial >关于ThinkPHP删除数据库记录的奇怪问题

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

WBOY
WBOYOriginal
2016-06-23 14:38:15884browse

我使用

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

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


回复讨论(解决方案)

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

搞定了,用

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

Statement:
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