YII 按照日期过滤不起作用,咋回事

php中文网
发布: 2016-06-13 12:47:54
原创
857人浏览过

YII 按照日期过滤不起作用,怎么回事?
YII  按照日期过滤不起作用,怎么回事?

模型

<br><?php <br /><br>
/**<br>
 * This is the model class for table "user".<br>
 *<br>
 * The followings are the available columns in table 'user':<br>
 * @property integer $id<br>
 * @property string $uname<br>
 */<br>
class Timefliter extends CActiveRecord<br>
{<br>
	/**<br>
	 * Returns the static model of the specified AR class.<br>
	 * @param string $className active record class name.<br>
	 * @return User the static model class<br>
	 */<br>
	public static function model($className=__CLASS__)<br>
	{<br>
		return parent::model($className);<br>
	}<br><br>
	/**<br>
	 * @return string the associated database table name<br>
	 */<br>
	public function tableName()<br>
	{<br>
		return 't_time';<br>
	}<br><br><br>
	public $starttime;<br>
	public $endtime;   	<br><br><br>
	/**<br>
	 * @return array validation rules for model attributes.<br>
	 */<br>
	public function rules()<br>
	{<br>
		// NOTE: you should only define rules for those attributes that<br>
		// will receive user inputs.<br>
		return array(<br>
			array('id', 'safe'),<br>
			//array('id', 'numerical', 'integerOnly'=&gt;true),<br>
			array('time', 'safe'),<br><br><br>
			// The following rule is used by search().<br>
			// Please remove those attributes that should not be searched.<br>
			array('id, time', 'safe', 'on'=&gt;'search'),<br>
		);<br>
	}<br><br>
	/**<br>
	 * @return array relational rules.<br>
	 */<br>
	public function relations()<br>
	{<br>
		// NOTE: you may need to adjust the relation name and the related<br>
		// class name for the relations automatically generated below.<br>
		return array(<br>
		);<br>
	}<br><br>
	/**<br>
	 * @return array customized attribute labels (name=&gt;label)<br>
	 */<br>
	public function attributeLabels()<br>
	{<br>
		return array(<br>
		'id'=&gt; '编号',<br>
        'time'=&gt; '时间',<br>
		);<br>
	}<br><br>
	/**<br>
	 * Retrieves a list of models based on the current search/filter conditions.<br>
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.<br>
	 */<br>
	public function search()<br>
	{<br>
		// Warning: Please modify the following code to remove attributes that<br>
		// should not be searched.<br><br>
		$criteria=new CDbCriteria;<br><br>
		$criteria-&gt;compare('id',$this-&gt;id);<br>
		$criteria-&gt;compare('time','&gt;='.$this-&gt;starttime);<br>
		$criteria-&gt;compare('time','endtime);<br><br>
		//是否开启模糊搜索,在后面true中实现<br>
		return new CActiveDataProvider($this, array(<br>
			'criteria'=&gt;$criteria,		    <br>
			//'pagination'=&gt;array('pagesize'=&gt;$pagesize?pagesize:$page),<br>
		    //'pagination'=&gt;array('pagesize'=&gt;$page), <div class="clear"></div>
登录后复制
最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号