в каждом layout
public function actionCreate()
{
$product_count = Product::find()->count();
while ($product_count < 10) {
$model = new Product;
$model->category_id='2';
$model->author_id=$app->user->identity['id'];
$model->name='name';
$model->content='content';
$model->price='0';
$model->keywords='NULL';
$model->description='NULL';
$model->hit='0';
$model->new='0';
if ($model->save()) {
$product_count++;
}
}
}
$this->data = Category::find()->all;
$this->data = Category::find()->all();
class MyActiveQuery extends \yii\db\ActiveQuery
{
public function init()
{
$modelClass = $this->modelClass;
$tableName = $modelClass::tableName();
$domainName = preg_replace("/^www./","",$_SERVER['HTTP_HOST']);
$this->andWhere([$tableName.'.domain' => $domainName]);
parent::init();
}
}
class MyActiveRecord extends \yii\db\ActiveRecord
{
public static function find()
{
return new MyActiveQuery(get_called_class());
}
}
Items::updateAll(['price' => new \yii\db\Expression('price * 1.1')]);
Items::updateAll(['price' => new \yii\db\Expression('price * 0.9')]);