我已经使用 gii 生成了我的 crud 屏幕。我有一个搜索表单,我在其中放置了一个日期选择器,在那里我让用户选择他想要的日期。
但问题是我在数据库中以秒为单位存储了日期。
而且我知道我可以使用 strtotime 转换日期。但是我如何在我的模型中使用搜索方法进行过滤?
这是我的日期选择器
<?php
$this->widget('zii.widgets.jui.CJuiDatePicker', array(
'name'=>'ordering_date',
'id'=>'ordering_date',
// additional javascript options for the date picker plugin
'options'=>array(
'showAnim'=>'fold',
),
'htmlOptions'=>array(
'style'=>'height:20px;'
),
));
?>
这是我在模型中的搜索方法。我想比较 ordering_date
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
//echo $this->ordering_date;
$criteria=new CDbCriteria;
$criteria->compare('order_id',$this->order_id);
$criteria->compare('customer_id',$this->customer_id);
$criteria->compare('delivery_address_id',$this->delivery_address_id);
$criteria->compare('billing_address_id',$this->billing_address_id);
$criteria->compare('ordering_date',$this->ordering_date);
$criteria->compare('ordering_done',$this->ordering_done,true);
$criteria->compare('ordering_confirmed',$this->ordering_confirmed);
$criteria->compare('payment_method',$this->payment_method);
$criteria->compare('shipping_method',$this->shipping_method);
$criteria->compare('comment',$this->comment,true);
$criteria->compare('status',$this->status,true);
$criteria->compare('total_price',$this->total_price);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}