Answer the question
In order to leave comments, you need to log in
Where is the best place to specify the condition?
Through the GET parameter, a condition is passed by which the value should be filtered. These values are cleared and stored in the model, then the data is retrieved using these conditions.
Where is it correct to specify the conditions (status, ko_from), in separate methods, or leave it like that?
Model method:
public function getActiveTransfers() {
$criteria = new CDbCriteria();
$criteria->with = ['good', 'koFrom', 'koTo'];
$criteria->condition .= 'status <> '.self::STATUS_RECD;
if($this->status)
$criteria->condition .= ' AND status ='.$this->status;
if($this->ko_from)
$criteria->condition .= ' AND ko_from ='.$this->ko_from;
return $this->getCActiveDataProvider($criteria);
}
Answer the question
In order to leave comments, you need to log in
From the point of view of code reuse, of course, it is better to put it into the methods of the model, but if this selection is used 1 time, then this is also quite normal.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question