What is the difference between component, extension & module in Yii

Components are the classes which can help you write the business logic on the basis of your models. Suppose all of your model files are using the same logic, So that logic can be written inside component instead of writing for each controller. Extensions are like the libraries, which basically are not dependent on your … Read more

Yii model to array?

I’m going on the assumption here that you only need to retrieve just the bare arrays, and not any associated model objects. This will do it: $model = Trips::model(); $trips = $model->getCommandBuilder() ->createFindCommand($model->tableSchema, $model->dbCriteria) ->queryAll(); This is like the Yii::app()->db->createCommand(‘SELECT * FROM tbl’)->queryAll(); examples, except: It’ll ask the model for the table name; you won’t … Read more

Yii2 : Active Record add Not In condition

Well all query operands seems now merged within in yii\db\QueryInterface::Where() per documentation an In condition can now be added using something like $query = MyModel::find()->where([‘attribute’=>$array]); for a not In condition it is slightly different format $query = MyModel::find()->where([‘not in’,’attribute’,$array]);