I’m trying to transfer this code below part to yii2. it works for Yii 1 at controller but i ve read that i don’t need criteria in Yii2 as it is not exist anymore. Can one show me how to run it in yii2? And also is CDBCriteria used better as ActiveQuery or Query in yii2?
public function search()
{
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('hashkey',$this->hashkey,true);
$criteria->compare('ch',$this->ch,true);
$criteria->compare('cimi',$this->cimi,true);
$criteria->compare('dir',$this->dir,true);
$criteria->compare('ourl',$this->ourl,true);
$criteria->compare('imob',$this->imob,true);
$criteria->compare('tStart',$this->tStart,true);
$criteria->compare('tAnswer',$this->tAnswer,true);
$criteria->compare('tEnd',$this->tEnd,true);
$criteria->compare('state',$this->state,true);
$criteria->compare('omob',$this->omob,true);
$criteria->compare('date',$this->date,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
public static function model($className=__CLASS__)
{
return parent::model($className);
}
public function getInCalls($fromDate = false, $toDate = false) {
$rawData = Yii::$app->db->createCommand ( "select id, date as Date, ch as Channel, dir as Direction, ourl as Twinkle, imob as IncomingCall, state as State from logs where tAnswer like '%+%' group by date order by date desc" )->queryAll ();
return $rawData;