yii

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-23 13:30:30
Original
913 people have browsed it

public function search() {        $criteria = new CDbCriteria;        if(!isset($_GET['Record_sort'])){            $criteria->order = 'record_order ASC' ;        }        $criteria->compare('record_id', $this->record_id, true);        $criteria->compare('record_display', $this->record_display, true);        $criteria->compare('record_series', $this->record_series, true);        return new CActiveDataProvider($this, array(            'criteria' => $criteria,        ));    }
Copy after login


$criteria->compare('record_series', $this->record_series, true);这句有什么用?$criteria->compare('record_series', 'A', true);  就是where 'record_series'='A' $criteria->compare('record_series', $this->record_series, true) 加这句和没加这句,显示出的结果是一样的
Copy after login


回复讨论(解决方案)

$criteria->compare('record_id', $this->record_id, true);
$criteria->compare('record_display', $this->record_display, true);
$criteria->compare('record_series', $this->record_series, true);

将产生类似这样的条件表达式
record_id like '%$this->record_id%' and record_display like '%$this->record_display%' and record_series like '%$this->record_series%'
因为第三个参数你指定为 true 是模糊查询(默认是 false 精确查询)
第四个参数默认为 and

至于为什么要这么写,那是你的业务需要,别人说不了什么

Related labels:
yii
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