select() public method

Sets the SELECT part of the query.
public select ( string | array | yii\db\Expression $columns, string $option = null )
$columns string | array | yii\db\Expression the columns to be selected. Columns can be specified in either a string (e.g. "id, name") or an array (e.g. ['id', 'name']). Columns can be prefixed with table names (e.g. "user.id") and/or contain column aliases (e.g. "user.id AS user_id"). The method will automatically quote the column names unless a column contains some parenthesis (which means the column contains a DB expression). A DB expression may also be passed in form of an [[Expression]] object. Note that if you are selecting an expression like `CONCAT(first_name, ' ', last_name)`, you should use an array to specify the columns. Otherwise, the expression may be incorrectly split into several parts. When the columns are specified as an array, you may also use array keys as the column aliases (if a column does not need alias, do not use a string key). Starting from version 2.0.1, you may also select sub-queries as columns by specifying each such column as a `Query` instance representing the sub-query.
$option string additional option that should be appended to the 'SELECT' keyword. For example, in MySQL, the option 'SQL_CALC_FOUND_ROWS' can be used.
 /**
  * Lists all Articlecomment models.
  * @return mixed
  */
 public function actionIndex()
 {
     $list = '';
     $post = Yii::$app->request->post();
     if ($post['id']) {
         $mod = new Query();
         $comment = $mod->select(['a.id', 'a.parentId', 'a.articleId', 'a.content', 'a.createTime', 'b.username'])->from('articlecomment as a')->leftJoin('user as b', 'a.userId = b.id')->where(['commentId' => $post['id']])->orderBy(['createTime' => 'DESC', 'id' => 'DESC'])->createCommand()->queryAll();
         if ($comment) {
             foreach ($comment as $v) {
                 $content = '回复@' . Articlecomment::getCommentByParId($v['parentId']) . ':' . $v['content'];
                 $ahtml = html::a(html::tag("i", "", ["class" => "fa fa-thumbs-o-up"]) . html::tag("span", "回复"), ["/main/viewart", "id" => $v["articleId"], "parId" => $v['id']]);
                 $list .= '<div class="infos small-comment' . $post['id'] . '" style="border:1px solid;">
                         	<div class="media-body markdown-reply content-body">
                         		<p>' . $content . '</p>
                         		<span class="opts pull-right">
                         			<a class="author" >' . $v["username"] . '</a>
                         			•
                         			<addr title="' . $v["createTime"] . '">' . Html::tag("span", Yii::$app->formatter->asRelativeTime($v["createTime"])) . '</addr>
                         			' . $ahtml . '
                                 </span>
                         	</div>
                         </div>';
             }
         }
     }
     $result = array('success' => true, 'message' => $list);
     echo json_encode($result);
     die;
     return $this->renderAjax('index', ['success' => true, 'message' => '']);
 }
Example #2
2
 public static function mostPopular()
 {
     $query = new Query();
     $query->select('meme_id, COUNT(meme_id) AS n_memes')->from('meme_vidmage')->groupBy('meme_id')->orderBy(['n_memes' => SORT_DESC])->limit(1);
     $row = $query->one();
     return self::findOne($row['meme_id']);
 }
Example #3
0
 /**
  * Prepare the DB query
  *
  * @return $this
  */
 public function prepare()
 {
     // Throw a exception if a required parameter is not defined
     $this->verifyRequiredParameters();
     // Build the query
     $this->query = new Query();
     $this->query->select('*');
     $this->query->from($this->getTableName());
     $this->query->where('app_id=:appId', [':appId' => $this->appId]);
     return $this;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query2 = new Query();
     if (isset($_GET['CallHistorySearch'])) {
         $monthStart = substr($_GET['CallHistorySearch']['start_time'], 5, 2);
         $monthEnd = substr($_GET['CallHistorySearch']['end_time'], 5, 2);
         $yearStart = substr($_GET['CallHistorySearch']['start_time'], 0, 4);
         $yearEnd = substr($_GET['CallHistorySearch']['end_time'], 0, 4);
         // cek interval month
         if ($monthStart == $monthEnd) {
             $obj = new CallHistory();
             $obj->setSuffixTable($yearStart . $monthStart);
             $query = $obj->find();
         } else {
             $obj = new CallHistory();
             $obj->setSuffixTable($yearStart . $monthStart);
             $query = $obj->find()->union($query2->select('*')->from('tbl_call_history_' . $yearEnd . $monthEnd), true);
             /* $obj = new CallHistory();
                $obj->setSuffixTable($yearStart.$monthStart);
                $query = new Query();
                $query2  = new Query();*/
             /*echo 'tbl_call_history_'.$yearStart.$monthStart;
                   echo 'tbl_call_history_'.$yearEnd.$monthEnd;
               die();*/
             $query->select('*')->from('tbl_csall_history_' . $yearStart . $monthStart);
             $query2->select('*')->from('tbl_call_history_' . $yearEnd . $monthEnd);
             $query->union($query2, true);
         }
     } else {
         // value default not result data
         $obj = new CallHistory();
         $obj->setSuffixTable('201509');
         $query = $obj->find();
     }
     /*$query = CallHistory::find()->union(
           $query2->select('*')
           ->from('tbl_call_history_201512')
       ,true);*/
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['forcePageParam' => false, 'pageSizeParam' => false, 'pageSize' => 10]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['J' => $this->J, 'Al' => $this->Al, 'duration' => $this->duration, 'Bl' => $this->Bl]);
     $query->andFilterWhere(['like', 'Anumber', $this->Anumber])->andFilterWhere(['like', 'Bnumber', $this->Bnumber])->andFilterWhere(['like', 'Zon', $this->Zon])->andFilterWhere(['like', 'Trunk1', $this->Trunk1])->andFilterWhere(['like', 'Trunk2', $this->Trunk2])->andFilterWhere(['like', 'setup_time', $this->setup_time])->andFilterWhere(['between', 'start_time', $this->start_time, $this->end_time]);
     // ->andFilterWhere(['like', 'setup_time', $this->setup_time]);
     // echo "<pre>";
     // print_r($query);
     return $dataProvider;
 }
Example #5
0
 /**
  * Получает список страниц для всплывающего окна
  * @return type
  */
 public function GetPagesList()
 {
     $query = new Query();
     $query->select(['p.name', 'm.name as module'])->join("LEFT JOIN", "module as m", "m.id = p.module")->from("backend__pages as p")->where(["p.visible" => 1, "p.active" => 1]);
     $result = $query->all();
     return $result;
 }
Example #6
0
 public function actionPermissions($name)
 {
     $role = $this->auth->getRoles();
     $roles = array_keys($role);
     $query = new Query();
     $query->select('*')->from('auth_item')->leftJoin('auth_item_child', ['and', 'auth_item.name=auth_item_child.child', 'auth_item_child.parent not in (\'' . implode("','", $roles) . '\')'])->where(['auth_item.type' => 2])->andWhere(['not like', 'name', '/']);
     $models = $query->all();
     $targetHasModels = $this->auth->getPermissionsByRole($name);
     $targetHasModels = array_keys($targetHasModels);
     //取用户所有权限的集合
     $hasModel = [];
     foreach ($roles as $rkey => $subRole) {
         $subPermission = $this->auth->getPermissionsByRole($subRole);
         $hasModel = array_merge($hasModel, $subPermission);
     }
     $hasModels = array_keys($hasModel);
     $hasModelsTree = [];
     foreach ($models as $key => $model) {
         if (in_array($model['name'], $hasModels)) {
             array_push($hasModelsTree, $model);
         } else {
             $subModels = $this->getSubModels($model, $models);
             foreach ($subModels as $subKey => $subModel) {
                 if (in_array($subModel['name'], $hasModels)) {
                     array_push($hasModelsTree, $model);
                 }
             }
         }
     }
     return $this->render('permissions', ['models' => $hasModelsTree, 'hasModels' => $targetHasModels]);
 }
 public function retrieve($className, $primaryKey)
 {
     $tableName = call_user_func([$className, "tableName"]);
     $current = $className::find()->where(['id' => $primaryKey])->asArray()->one();
     $query = new Query();
     $query->select(['field_name', 'old_value', 'event', 'action_uuid', 'created_at']);
     $query->from($this->tableName);
     $query->where(['field_id' => $primaryKey, 'table_name' => $tableName]);
     $query->orderBy(['created_at' => SORT_ASC]);
     $changes = [];
     foreach ($query->all() as $element) {
         $uuid = $element['action_uuid'];
         if (!isset($changes[$uuid])) {
             $changes[$uuid] = $current;
         }
         $changes[$uuid][$element['field_name']] = $element['old_value'];
         $current = $changes[$uuid];
     }
     $models = array_map(function ($element) use($className) {
         $model = $className::instantiate($element);
         $className::populateRecord($model, $element);
         return $model;
     }, $changes);
     return new ArrayDataProvider(['allModels' => array_values($models)]);
 }
Example #8
0
 public function getPrivilege($userId = null)
 {
     $db = new Query();
     $db->select("group_id")->from("privilege")->where("user_id = '{$userId}' ");
     $groupUser = $db->all();
     $GroupUserArr = array();
     foreach ($groupUser as $Guser) {
         $GroupUserArr[] = "'" . $Guser['group_id'] . "'";
     }
     $GroupUser = implode(",", $GroupUserArr);
     if (!empty($GroupUser)) {
         $GroupUserVal = $GroupUser;
     } else {
         $GroupUserVal = "''";
     }
     if (!empty($GroupUserVal)) {
         $Privilege = GroupPcu::find()->where('group_id IN(' . $GroupUserVal . ')')->all();
         $PcuArr = array();
         foreach ($Privilege as $rs) {
             $PcuArr[] = $rs['hospcode'];
         }
     } else {
         $PcuArr = null;
     }
     Yii::$app->session['privilege'] = $PcuArr;
 }
Example #9
0
 public function actionProspek()
 {
     $regional = Regional::find()->all();
     $query = new Query();
     $data = array();
     foreach ($regional as $rows) {
         $query->select('COUNT(*) AS JUMLAH')->from('TABLE1')->join('LEFT OUTER JOIN', 'TABLE3', 'TABLE3.FIELD1 = TABLE1.FIELD2')->where(['TABLE3.FIELD7' => $rows->FIELD1])->andWhere('TABLE3.FIELD3 IS NOT NULL')->all();
         $handphone = $query->createCommand()->queryScalar();
         $query->select('COUNT(*) AS JUMLAH')->from('TABLE1')->join('LEFT OUTER JOIN', 'TABLE3', 'TABLE3.FIELD1 = TABLE1.FIELD2')->where(['TABLE3.FIELD7' => $rows->FIELD1])->andWhere('TABLE3.FIELD6 IS NOT NULL')->all();
         $email = $query->createCommand()->queryScalar();
         $query->select('COUNT(*) AS JUMLAH')->from('TABLE1')->join('LEFT OUTER JOIN', 'TABLE3', 'TABLE3.FIELD1 = TABLE1.FIELD2')->join('LEFT OUTER JOIN', 'TABLE2', 'TABLE2.FIELD1 = TABLE3.FIELD2')->where(['TABLE3.FIELD7' => $rows->FIELD1])->andWhere('TABLE2.FIELD7 IS NOT NULL')->all();
         $phone = $query->createCommand()->queryScalar();
         array_push($data, array('regional' => $rows->FIELD1, 'handphone' => $handphone, 'email' => $email, 'phone' => $phone));
     }
     return $this->render('prospek', ['data' => $data, 'regional' => $regional]);
 }
Example #10
0
 public static function getArticleCategories($articleId)
 {
     $query = new Query();
     $query->select('article_categories.*,article_categories_bind.article_id as active')->from('article_categories')->join('left outer join', 'article_categories_bind', 'article_categories.id = article_categories_bind.categories and
             article_categories_bind.article_id= ' . $articleId)->orderBy('article_categories.id');
     return $query->all();
 }
 /**
  * Updates an existing PageData model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id_page
  * @param string $language
  * @return mixed
  */
 public function actionUpdate($id_page, $language)
 {
     $model = $this->findModel($id_page, $language);
     $model->setScenario('update');
     //if (!Yii::$app->user->can('ownAction', ['model' => $model])) {
     //    throw new ForbiddenHttpException('You are not allowed to perform this action.');
     //}
     /* copy to other languages */
     $languages = Message::getLocaleList();
     $q = new Query();
     $pageLang = $q->select(['language'])->from('{{%core_page_data}}')->where(['id_page' => $id_page])->all();
     foreach ($pageLang as $pl) {
         if (in_array($pl['language'], array_keys($languages))) {
             unset($languages[$pl['language']]);
         }
     }
     //var_dump($languages);
     /* submitted */
     if (Yii::$app->request->isPost) {
         /* page data */
         $model->load(Yii::$app->request->post());
         $model->page->load(Yii::$app->request->post());
         $model->page->save();
         $model->save();
         return $this->redirect(['update', 'id_page' => $model->id_page, 'language' => $model->language]);
     } else {
         return $this->render('update', ['model' => $model, 'languages' => $languages]);
     }
 }
Example #12
0
 public function actionIndex($date = null)
 {
     //    $apteki=LogReestr::find()->where(['resstr' => 'apteki'])->all();
     if (!$date) {
         $date = date('Y-m');
     }
     $db = new Query();
     $db->from(LogReestr::tableName());
     $db->select(['log_reestr.created_at', 'log_reestr.address', 'log_reestr.resstr', 'log_reestr.id_resstr', 'log_reestr.action', 'log_reestr.name', 'log_reestr.ur_l_id', 'log_reestr.id_resstr', 'log_reestr.change', 'users.username', 'log_reestr.id_resstr']);
     $db->where(['=', 'resstr', 'apteki']);
     $db->leftJoin('users', "users.id = log_reestr.user");
     $db->orderBy('log_reestr.created_at DESC');
     $date_search = $date . '%';
     $db->andWhere(['like', 'log_reestr.created_at', $date_search, false]);
     $apteki = $db->all();
     //   $apteki_count = $db->count();
     $db = new Query();
     $db->from(LogReestr::tableName());
     $db->select(['log_reestr.created_at', 'log_reestr.address', 'log_reestr.resstr', 'log_reestr.id_resstr', 'log_reestr.name', 'log_reestr.action', 'log_reestr.change', 'users.username', 'log_reestr.id_resstr']);
     $db->where(['=', 'resstr', 'ur_l']);
     $db->leftJoin('users', "users.id = log_reestr.user");
     $db->andWhere(['like', 'log_reestr.created_at', $date_search, false]);
     $db->orderBy('log_reestr.created_at DESC');
     $ur_l = $db->all();
     // $ur_l_count = $db->count();
     $statm = \Yii::$app->db->createCommand("SELECT   users.username ,  COUNT(*) as count FROM  log_reestr  INNER JOIN users  ON users.id=log_reestr.user\n    where log_reestr.created_at like '" . $date . "%'\n        GROUP BY USER order by count DESC");
     $stat = $statm->queryAll();
     $statAllm = \Yii::$app->db->createCommand("SELECT COUNT(*) as count FROM  log_reestr\n    where log_reestr.created_at like '" . $date . "%'       ");
     $statAll = $statAllm->queryOne();
     return $this->render('index', ['apteki' => $apteki, 'ur_l' => $ur_l, 'date' => $date, 'stat' => $stat, 'statAll' => $statAll]);
 }
Example #13
0
 public function getAllMatieres()
 {
     $query_mat = new Query();
     $query_mat->select('id,nom,nb_tours_complete, color, color_hl, color_rgb')->from('matiere')->orderBy('id');
     $matieres = $query_mat->all();
     return $this->arrayToMatiereList($matieres);
 }
 public function getIdByNumTitre($num, $titre)
 {
     $query = new Query();
     $query->select('id')->from('annales_track')->where('num = ' . $num . ' AND titre LIKE "' . $titre . '"');
     $data = $query->all();
     return $data[0]['id'];
 }
Example #15
0
 public function getPhotos()
 {
     $query = new Query();
     $query->select('id, name, path')->from('{{%home_photo}}')->where('album_id=:id', [':id' => $this->id]);
     $photos = Tools::Pagination($query);
     return ['photos' => $photos['result'], 'pages' => $photos['pages']];
 }
Example #16
0
 public static function getUsersModulesList()
 {
     $query = new Query();
     $query->select('modules.*,users_modules.user_id as active')->from('modules')->join('left join', 'users_modules', 'modules.id = users_modules.module_id and
             users_modules.user_id= ' . Yii::$app->user->id)->orderBy('modules.id');
     return $query->all();
 }
Example #17
0
 /**
  * Returns calculated availability
  */
 public function getAvailability()
 {
     $query = new Query();
     $query->select('Product, Warehouse, Availability')->from('GetProductAvailability')->where("Product = {$this->ID}");
     $availability = $query->all();
     return $availability;
 }
Example #18
0
 public function init()
 {
     parent::init();
     $db = Instance::ensure($this->db, Connection::className());
     $query = new Query();
     $this->ticket = $query->select(['*'])->from($this->table)->createCommand($db)->queryAll();
 }
Example #19
0
 private function CantidadTotalRegistros()
 {
     $consulta = new Query();
     $consulta->select('id')->from($this->tabla);
     $consulta = $consulta->all();
     return count($consulta);
 }
Example #20
0
 /**
  * Функция пополучения списка приглашенных пользователей
  */
 public function getUsers()
 {
     $query = new Query();
     $query->select('email')->from('users')->where('leader_id = :id', array(':id' => Yii::$app->user->getId()));
     $rows = $query->all();
     return $rows;
 }
Example #21
0
 /**
  * @inheritdoc
  */
 public function writeSession($id, $data)
 {
     // exception must be caught in session write handler
     // http://us.php.net/manual/en/function.session-set-save-handler.php
     try {
         $userId = new Expression('NULL');
         if (!Yii::$app->user->isGuest) {
             $userId = Yii::$app->user->id;
         }
         $expire = time() + $this->getTimeout();
         $query = new Query();
         $exists = $query->select(['id'])->from($this->sessionTable)->where(['id' => $id])->createCommand($this->db)->queryScalar();
         if ($exists === false) {
             $this->db->createCommand()->insert($this->sessionTable, ['id' => $id, 'data' => $data, 'expire' => $expire, 'user_id' => $userId])->execute();
         } else {
             $this->db->createCommand()->update($this->sessionTable, ['data' => $data, 'expire' => $expire, 'user_id' => $userId], ['id' => $id])->execute();
         }
     } catch (\Exception $e) {
         $exception = ErrorHandler::convertExceptionToString($e);
         // its too late to use Yii logging here
         error_log($exception);
         echo $exception;
         return false;
     }
     return true;
 }
Example #22
0
 public function getPsychologistProblemsList($psychologistId)
 {
     $query = new Query();
     $query->select('problems.*')->from('problems')->join('left outer join', 'psychologist_problems', 'problems.id = psychologist_problems.problem_id and
             psychologist_problems.psychologist_id= ' . $psychologistId)->orderBy('problems.id');
     return $query->all();
 }
 /**
  * @return string
  */
 public function actionSendorder()
 {
     $session = Yii::$app->session;
     $session->open();
     $model = new Orders();
     $query = new Query();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $model->total_sum = $_SESSION['total_price'];
         $model->date = date('d-m-Y');
         $model->time = Yii::$app->getFormatter()->asTime(time());
         $id = array_keys($_SESSION['cart']);
         $model->complite = 0;
         for ($i = 0; $i < count($id); $i++) {
             $products[] = $query->select('title')->from('data')->where(['id' => $id[$i]])->one();
             $products[$i]['quantity'] = $_SESSION['cart'][$id[$i]]['quant'];
         }
         $model->adres = strip_tags($model->adres);
         $model->product = serialize($products);
         $model->save();
         //				$session->destroy();
         //////
         $mrh_login = Yii::$app->params['mrh_login'];
         $mrh_pass1 = Yii::$app->params['mrh_pass1'];
         $inv_id = $model->id;
         $inv_desc = Yii::$app->params['inv_desc'];
         $out_summ = $model->total_sum;
         $crc = md5("{$mrh_login}:{$out_summ}:{$inv_id}:{$mrh_pass1}");
         return $this->render('pay', ['name' => $model->name, 'out_summ' => $out_summ, 'mrh_login' => $mrh_login, 'inv_id' => $inv_id, 'inv_desc' => $inv_desc, 'crc' => $crc]);
     } else {
         return $this->render('error', ['message' => "Ошибка приложения!"]);
     }
 }
Example #24
0
 public function getAllCas()
 {
     $query = new Query();
     $query->select('num,cpt,sumnote,year')->from('aggreg_cas_weekly')->orderBy('num ASC');
     $data = $query->all();
     return $this->arrayToWeekCas($data);
 }
Example #25
0
 /**
  * Lists all Feed models.
  * @return mixed
  */
 public function actionIndex()
 {
     $query = new Query();
     $query->select('id, content, feed_data, template, created_at')->from('{{%home_feed}}')->where('user_id=:user_id', [':user_id' => Yii::$app->user->id])->orderBy('created_at DESC');
     $pages = Tools::Pagination($query);
     return $this->render('index', ['feeds' => $pages['result'], 'pages' => $pages['pages']]);
 }
Example #26
0
 public static function getVideosCategories($videoId)
 {
     $query = new Query();
     $query->select('video_categories.*,video_categories_bind.video_id as active')->from('video_categories')->join('left outer join', 'video_categories_bind', 'video_categories.id = video_categories_bind.category_id and
             video_categories_bind.video_id= ' . $videoId)->orderBy('video_categories.id');
     return $query->all();
 }
Example #27
0
 public function init()
 {
     parent::init();
     if ($this->page == 'index') {
         if ($this->cat == 'all' or $this->cat == null) {
             $query = Logotypes::find()->limit(15);
         } else {
             $query_cat = new Query();
             $query_cat->select('id')->from('category')->where(['name' => $this->cat]);
             $cat_id = $query_cat->all()[0]['id'];
             $query = Logotypes::find()->limit(15)->where(['category' => $cat_id]);
         }
         $logos = $query->all();
         shuffle($logos);
     } else {
         if ($this->cat == 'all' or $this->cat == null) {
             $query = Logotypes::find();
         } else {
             $query_cat = new Query();
             $query_cat->select('id')->from('category')->where(['name' => $this->cat]);
             $cat_id = $query_cat->all()[0]['id'];
             $query = Logotypes::find()->where(['category' => $cat_id]);
         }
         $countQuery = clone $query;
         $pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => 15]);
         $logos = $query->offset($pages->offset)->limit($pages->limit)->all();
         $this->pages = $pages;
     }
     $this->logos = $logos;
 }
Example #28
0
 public function actionIndex()
 {
     $query = new Query();
     $query->select('*')->from('auth_item')->leftJoin('auth_item_child', 'auth_item.name=auth_item_child.child')->where(['auth_item.type' => 1]);
     $models = $query->all();
     return $this->render('index', ['models' => $models]);
 }
Example #29
0
 public function findAllAuthors()
 {
     $query = new Query();
     $authorsArrayDataProvider = new ArrayDataProvider(['allModels' => $query->select(["CONCAT(firstname, ' ', lastname) AS full_name", 'id'])->from('authors')->all(), 'pagination' => false, 'key' => 'id']);
     $authors = $authorsArrayDataProvider->allModels;
     return $authors;
 }
 public function up()
 {
     $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
     $this->createTable(Thumbnail::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'img_id' => 'INT UNSIGNED NOT NULL', 'thumb_path' => 'VARCHAR(255) NOT NULL', 'size_id' => 'INT UNSIGNED NOT NULL'], $tableOptions);
     $this->createTable(ThumbnailSize::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'width' => 'INT UNSIGNED NOT NULL', 'height' => 'INT UNSIGNED NOT NULL', 'default_watermark_id' => 'INT UNSIGNED NULL', 'resize_mode' => 'ENUM(\'' . ManipulatorInterface::THUMBNAIL_INSET . '\',\'' . ManipulatorInterface::THUMBNAIL_OUTBOUND . '\') DEFAULT \'' . ManipulatorInterface::THUMBNAIL_INSET . '\''], $tableOptions);
     $this->createTable(Watermark::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'watermark_path' => 'VARCHAR(255) NOT NULL', 'position' => 'enum(\'TOP LEFT\',\'TOP RIGHT\',\'BOTTOM LEFT\',\'BOTTOM RIGHT\',\'CENTER\') NOT NULL DEFAULT \'TOP LEFT\''], $tableOptions);
     $this->createTable(ThumbnailWatermark::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'thumb_id' => 'INT UNSIGNED NOT NULL', 'water_id' => 'INT UNSIGNED NOT NULL', 'compiled_src' => 'VARCHAR(255) NOT NULL'], $tableOptions);
     $defaultSize = new ThumbnailSize();
     $defaultSize->setAttributes(['width' => 80, 'height' => 80]);
     $defaultSize->save();
     $query = new Query();
     $query->select('*')->from('image');
     $images = $query->all();
     foreach ($images as $image) {
         try {
             if (file_exists(Yii::getAlias("@webroot{$image['image_src']}")) === true) {
                 $stream = fopen(Yii::getAlias("@webroot{$image['image_src']}"), 'r+');
                 Yii::$app->getModule('image')->fsComponent->putStream($image['filename'], $stream);
             } else {
                 $this->delete(Image::tableName(), ['id' => $image['id']]);
             }
         } catch (\Exception $e) {
             echo sprintf('[%s] %s || %s' . PHP_EOL, $e->getMessage(), $image['image_src'], $image['filename']);
         }
     }
     $this->dropColumn(Image::tableName(), 'thumbnail_src');
     $this->dropColumn(Image::tableName(), 'image_src');
     $this->insert(BackendMenu::tableName(), ['parent_id' => 1, 'name' => 'Images', 'icon' => 'picture-o', 'sort_order' => 10, 'route' => '', 'added_by_ext' => 'core', 'rbac_check' => 'content manage', 'translation_category' => 'app']);
     $image_menu_id = Yii::$app->db->lastInsertID;
     $this->batchInsert(BackendMenu::tableName(), ['parent_id', 'name', 'route', 'added_by_ext', 'rbac_check', 'translation_category'], [[$image_menu_id, 'Thumbnails sizes', 'image/backend-thumbnail-size/index', 'core', 'content manage', 'app'], [$image_menu_id, 'Create thumbnails', 'image/backend-thumbnail/index', 'core', 'content manage', 'app'], [$image_menu_id, 'Watermarks', 'image/backend-watermark/index', 'core', 'content manage', 'app'], [$image_menu_id, 'Broken images', 'image/backend-error-images/index', 'core', 'content manage', 'app']]);
     $this->createTable(ErrorImage::tableName(), ['id' => 'INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT', 'img_id' => 'INT UNSIGNED NOT NULL', 'class_name' => 'VARCHAR(255) NOT NULL'], $tableOptions);
     $this->insert(Task::tableName(), ['action' => 'images/check-broken', 'type' => Task::TYPE_REPEAT, 'initiator' => 1, 'name' => 'Check broken images', 'cron_expression' => '* */1 * * *']);
     $this->insert(Configurable::tableName(), ['module' => 'image', 'sort_order' => 8, 'section_name' => 'Images']);
 }