3.1以上版本支持field("a,b,c",true)的写法,这样查询出的field就会过滤掉a,b,c这三个字段。但是如果写成field("a, b, c", true)则只会过滤掉a则会把b,c显示出来。因为多了空格
错误写法:
$this->field("id,issueID,landscapeCoverID, portraitCoverID,bookIndex, updateTime,updateUser,editTime", true)
->where("id=$bookID")->find();
转换成的sql
SELECT `book`,`bookKicker`,`readerType`,`orientation`,`description`,`libraryFilter`,`portraitCoverID`,
`updateTime`,`versionID`,`horizontalNavigationStyle`,`verticalNavigationStyle`,`enableFlip` FROM `plan_plan` WHERE ( id=5001212 ) LIMIT 1
只要带有空格都会显示出来,不会被过滤掉。
正确写法:
$bookData = $this->field("id,issueID,landscapeCoverID,portraitCoverID,bookIndex,updateTime,updateUser,editTime", true)
->where("id=$bookID")->find();
所有field都不带空格。
SQL:
SELECT `book`,`bookKicker`,`readerType`,`orientation`,`description`,`libraryFilter`,`versionID`,`horizontalNavigationStyle`,`verticalNavigationStyle`,`enableFlip` FROM `plan_plan` WHERE ( id=5001212 ) LIMIT 1