Hi,
I have a problem with RBAC adding additional “where” statement in my ActiveRecord query. How do I remove the Where Statement that contain the " Role = ‘admin’ "
FYI,
-
In my Model I do no have any override for the find()
-
I am using detkrium RBAC.
-
I do not have role column in the table (myrules) as the results is applicable to every user.
Database Exception – yii\db\Exception
SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘role’ in ‘where clause’
The SQL being executed was: SELECT * FROM myrules
WHERE role NOT LIKE "admin" ORDER BY seq_no
LIMIT 20
Error Info: Array
(
[0] => 42S22
[1] => 1054
[2] => Unknown column 'role' in 'where clause'
Model
namespace app\models;
use Yii;
class MyRulesModel extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'myrules';
}
…
}
Controller
use app\models\MyRulesModel;
use yii\data\Pagination;
use yii\db\ActiveRecord;
use yii\data\ActiveDataProvider;
use yii\helpers\ArrayHelper;
use yii\base\Model;
class Controller MyruleController extends \yii\web\Controller
public function actionMyrules()
{
$model = new MyRulesModel;
$query = MyRulesModel::find()->orderBy("seq_no ASC");
$dataprovider = new ActiveDataProvider([‘query’=> $query ,
'pagination'=> ['pagesize'=>20]]);
echo $this->render(’/network/myrules’,[‘my_model’=>$dataprovider]);
}