Yii? CDbCriteria

Source: Internet
Author: User
Yii? CDbCriteria
Select Date Form and Date To, and click the Search button To query the public function search () {$ criteria = new CDbCriteria for the two days; if (isset ($ _ GET ['date1']) & isset ($ _ GET ['date2']) {$ criteria-> addBetweenCondition ('news _ date ', $ _ GET ['date1'], $ _ GET ['date2']);} // This function has been implemented // The problem is: if you only select Date Form, display all data after Date Form. // if only Date To is selected, return new CActiveDataProvider ($ this, array ('criteria '=> $ criteria ,));}


Reply to discussion (solution)

Code for you, almost the same

public function failureCat()        {                $criteria = new CDbCriteria;                $criteria->compare('t.failItem', $this->failItem);                $criteria->compare('logInfo.logProcess', $this->failStation);                $criteria->compare('logInfo.logUpdate', '>=' . $this->dateToDatetime($this->startDate, 1));                $criteria->compare('logInfo.logUpdate', '<=' . $this->dateToDatetime($this->endDate));                $criteria->with = array('logInfo');                return new CActiveDataProvider('TestLogFail', array(                    'pagination' => array(                        'pageSize' => Yii::app()->params['pageSize'],                    ),                    'criteria' => $criteria,                    'sort' => array(                        'defaultOrder' => 'logInfo.logUpdate desc',                    ),                ));        }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.