mithila
(Mithila)
May 14, 2011, 6:37am
1
Hi all,
I have a table called product_stock.
It has the fields product_name, stock and stock_date.
I want to modify my search so that when i filter a product only the latest stock is filtered i.e i want the product stock based on the latest stock_date.
Can anybody tell me how to do this?
Thanks.
francis
(Francis Tm)
May 14, 2011, 6:43am
2
filter in search? you mean CGridView or just normal CActiveRecord::findAll() ?
mithila
(Mithila)
May 14, 2011, 7:17am
3
i mean CGRIDview in the advanced search
francis
(Francis Tm)
May 14, 2011, 8:06am
4
you can find a method in AR model called search, and it has lines like belows:
$criteria->compare('stock',$this->stock ,true);
$criteria->compare('stock_date',$this->stock_date,true);
$criteria->compare('product_name',$this->product_name,true);
and after add a line like
$criteria->compare('stock',$this->stock ,true);
$criteria->compare('stock_date',$this->stock_date,true);
$criteria->compare('product_name',$this->product_name,true);
$criteria->order = 't.stock_date DESC';