YII filtering by date does not work. what is going on?

Source: Internet
Author: User
YII filtering by date does not work. why? YII & nbsp; filtering by date does not work. why? Model & lt ;? Php/** & nbsp; * & nbsp; This & nbsp; is & nbsp; the & nbsp; model & nbs YII does not work by date. why?
YII filtering by date does not work. why?

Model



/**
* This is the model class for table "user ".
*
* The followings are the available columns in table 'user ':
* @ Property integer $ id
* @ Property string $ uname
*/
Class Timefliter extends CActiveRecord
{
/**
* Returns the static model of the specified AR class.
* @ Param string $ className active record class name.
* @ Return User the static model class
*/
Public static function model ($ className =__ CLASS __)
{
Return parent: model ($ className );
}

/**
* @ Return string the associated database table name
*/
Public function tableName ()
{
Return 't_ time ';
}


Public $ starttime;
Public $ endtime;


/**
* @ Return array validation rules for model attributes.
*/
Public function rules ()
{
// NOTE: you shocould only define rules for those attributes that
// Will receive user inputs.
Return array (
Array ('id', 'Safe '),
// Array ('id', 'numerical ', 'integeronly' => true ),
Array ('time', 'Safe '),


// The following rule is used by search ().
// Please remove those attributes that shocould not be searched.
Array ('Id, Time', 'Safe ', 'on' => 'Search '),
);
}

/**
* @ Return array relational rules.
*/
Public function relations ()
{
// NOTE: you may need to adjust the relation name and the related
// Class name for the relations automatically generated below.
Return array (
);
}

/**
* @ Return array customized attribute labels (name => label)
*/
Public function attributeLabels ()
{
Return array (
'Id' => 'number ',
'Time' => 'time ',
);
}

/**
* Retrieves a list of models based on the current search/filter conditions.
* @ Return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
Public function search ()
{
// Warning: Please modify the following code to remove attributes that
// Shocould not be searched.

$ Criteria = new CDbCriteria;

$ Criteria-> compare ('id', $ this-> id );
$ Criteria-> compare ('time', '> ='. $ this-> starttime );
$ Criteria-> compare ('time', '<='. $ this-> endtime );

// Whether to enable fuzzy search, which is implemented in true
Return new CActiveDataProvider ($ this, array (
'Criteria '=> $ criteria,
// 'Pagination' => array ('pagesize' => $ pagesize? Pagesize: $ page ),
// 'Pagination' => array ('pagesize' => $ page ),

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.