all() public method

Executes the query and returns all results as an array.
public all ( Connection $db = null ) : array
$db Connection the database connection used to generate the SQL statement. If this parameter is not given, the `db` application component will be used.
return array the query results. If the query results in nothing, an empty array will be returned.
Example #1
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 #2
0
 public static function getPostByTags()
 {
     $query = new Query();
     $query->from('tags')->join('JOIN', 'posts_tags', 'posts_tags.tag_id = tags.id')->join('JOIN', 'posts', 'posts_tags.post_id = posts.id')->where(['tags.name' => $_GET['tags']]);
     $rows = $query->all();
     return $rows;
 }
Example #3
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 #4
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 #5
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);
 }
Example #6
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();
 }
 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 #8
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]);
 }
 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']);
 }
 public static function getCustomFieldsArray($tour_id)
 {
     $query = new Query();
     $query->from(CustomFields::tableName())->where([CustomFields::FIELD_TOUR_ID => $tour_id]);
     $result = $query->all();
     return $result;
 }
Example #11
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 #12
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]);
 }
Example #13
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 #14
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();
 }
Example #15
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 #16
0
 public function actionTraining($id)
 {
     $q = new Query();
     $q->from('train')->where('HeroId=:id', array(':id' => $id));
     $training = $q->all();
     return json_encode($training);
 }
Example #17
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 #18
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 #19
0
 public function actionIndex($user = null, $date = null, $trimestr = null, $scroll = null)
 {
     if (\Yii::$app->user->identity->status == 3) {
         $user = \Yii::$app->user->identity->id;
     }
     //$model = Preparats::find()->where(['region_id' => $region])->orderBy('name')->all();
     if ($user) {
         //$apteki = Apteki::find()->where(['pi_id' => $user, 'farmopeka' => '1'])->orderBy('address')->all();
         $query = new Query();
         $query->select(['ur_l.name', 'apteki.address', 'apteki.id']);
         $query->from('apteki');
         $query->LeftJoin('ur_l', 'ur_l.id = apteki.ur_l_id');
         $query->andFilterWhere(['=', 'apteki.farmopeka', '1']);
         $query->andFilterWhere(['=', 'apteki.pi_id', $user]);
         //$query->orderBy('ur_l.name,apteki.address');
         $query->orderBy(['ur_l.name' => SORT_ASC, 'apteki.address' => SORT_ASC]);
         $apteki = $query->all();
     }
     if (!$date) {
         $date = date('Y-m-01');
     }
     //   if (!trimestr) $trimestr = Visitors::getTrimestr($date);
     if ($user) {
         $table = Visitors::getTable($user, $apteki, $date, $trimestr, $scroll);
     }
     // print \Yii::$app->params['infoEmail'];
     //Количество привязвнных ир.лиц и розничных точек
     $count['ur'] = Ur::find()->where(['pi_id' => $user])->andWhere(['farmopeka' => 1])->count();
     $count['apteki'] = Apteki::find()->where(['pi_id' => $user])->andWhere(['farmopeka' => 1])->count();
     return $this->render('index', ['user' => $user, 'table' => $table, 'date' => $date, 'trimestr' => $trimestr, 'count' => $count, 'scroll' => $scroll]);
 }
Example #20
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);
 }
 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)]);
 }
 /**
  * 获得数据库对应数据
  * @return type
  */
 public static function getServer()
 {
     $query = new Query();
     $query->select("server")->from("AccessLog_Iismost")->distinct();
     $dbtypes = $query->all();
     $dbtype_item = ArrayHelper::map($dbtypes, "server", "server");
     return $dbtype_item;
 }
Example #23
0
File: Geo.php Project: pumi11/aau
 public static function getRegion()
 {
     $db = new yii\db\Query();
     $db->select('id', 'name');
     $db->from('region');
     $db->orderBy('name');
     return $db->all();
 }
Example #24
0
 public function getQuiz($id)
 {
     $query = new Query();
     $query->select('quiz_questions.id as qid,quiz_questions.*,questions_answers.*')->from('quiz_questions');
     $query->join('join', 'questions_answers', 'quiz_questions.id=question_id');
     $query->where('quiz_questions.quiz_id=' . $id);
     return $this->_group_by($query->all(), 'qid');
 }
Example #25
0
File: Lists.php Project: pumi11/aau
 public static function getApteki($id)
 {
     $db = new Query();
     //$db->select('id','name');
     $db->where(['=', 'ur_l_id', $id]);
     $db->from('apteki');
     return $db->all();
 }
Example #26
0
 public function search_params($params)
 {
     if (empty($params['tip_id'])) {
         return [];
     }
     $query = new Query();
     $query->select('p.id, p.name, p.title')->from('t_tovar t')->leftJoin('t_value v', 'v.tovar_id=t.id')->leftJoin('t_param p', 'v.param_id=p.id')->where('t.tip_id=:tip_id', [':tip_id' => $params['tip_id']])->andWhere('not p.id is null')->orderBy('p.name')->distinct();
     return $query->all();
 }
 public function getThemes($params = null)
 {
     $query = new Query();
     $query->select('id, title, description, status, id_category')->from('forum_category')->where(['id_category' => NULL]);
     $items = $query->all();
     if ($items != null) {
         return $items;
     }
 }
Example #28
0
 public static function getPopularVideos()
 {
     $query = new Query();
     $query->select('videos.*,(SELECT  COUNT(*) FROM videos_comments WHERE videos.id = videos_comments.video_id) as commentsCount');
     $query->from('videos');
     $query->orderBy('commentsCount DESC');
     $query->limit('4');
     return $query->all();
 }
Example #29
0
 public static function getMostActive()
 {
     $query = new Query();
     $query->select('profile.*,(SELECT  COUNT(*) FROM discussion_post_reply WHERE profile.user_id = discussion_post_reply.user_id) as repliesCount');
     $query->from('profile');
     $query->orderBy('repliesCount DESC');
     $query->limit('4');
     return $query->all();
 }
Example #30
0
 public function getDailyCpt($code, $mat_id)
 {
     $query = new Query();
     $query->select('cpt, mkb_cpt as mkb')->from('aggreg_daily')->where(" code LIKE '" . $code . "' AND mat_id = " . $mat_id);
     $data = $query->all();
     $cpt = $data[0]['cpt'];
     $mkb = $data[0]['mkb'];
     return array('cpt' => $cpt, 'mkb' => $mkb);
 }