Heim  >  Artikel  >  Backend-Entwicklung  >  thinkphp问题

thinkphp问题

WBOY
WBOYOriginal
2016-09-06 08:57:08962Durchsuche

我下载的是最新的tp3.2.3,我在执行语句的时候遇到问题

就是where或者add,update的时候,

参数错误都不会报错,而是直接过滤掉,我想问下,是我配置的问题吗

问题:比方说user表 字段 username password,我在add的时候,把username写成了usernames,结果语句成功了,不过只插入了password

查询user表,我where条件里面,故意把array('username'=>'aaa')写成array('usernames'=>'aaa')
结果sql直接过滤成了空条件,也就是变成了select * from user ;

debug有开,表明错误会报错,可是字段错误不报错!打印最后一条sql语句的时候,显示的那些错误的字段或者条件,全部被过滤掉了。

回复内容:

我下载的是最新的tp3.2.3,我在执行语句的时候遇到问题

就是where或者add,update的时候,

参数错误都不会报错,而是直接过滤掉,我想问下,是我配置的问题吗

问题:比方说user表 字段 username password,我在add的时候,把username写成了usernames,结果语句成功了,不过只插入了password

查询user表,我where条件里面,故意把array('username'=>'aaa')写成array('usernames'=>'aaa')
结果sql直接过滤成了空条件,也就是变成了select * from user ;

debug有开,表明错误会报错,可是字段错误不报错!打印最后一条sql语句的时候,显示的那些错误的字段或者条件,全部被过滤掉了。

在模型文件中 打印sql:echo $this->getLastSql(),看看执行语句。

debug模式有没有开?

这是thinkphp的过滤效果,add()会把不符合要求的字段过滤掉。你这么问说明你没有看仔细文档。

thinkphp本来就是可以过滤掉你错误的字段。他只把正确的字段写进去。不报错误的。他会当成你没有传这个字段处理

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn