最新消息: 新版网站上线了!!!

yii2原生态sql操作

$find_query = "SELECT * FROM business WHERE status='Enabled' ";

 $query = Business::findBySql($find_query);

//$query = Business::find()->where(['status' => 'Enabled']);

$countQuery = count($query->all());

$pages = new Pagination(['totalCount' => $countQuery, 'defaultPageSize' => 10]);

$data_rows = $query->offset($pages->offset)
        ->limit($pages->limit)
        ->all();

转载请注明:谷谷点程序 » yii2原生态sql操作