当前位置: 首页>>代码示例>>PHP>>正文


PHP Query::limit方法代码示例

本文整理汇总了PHP中yii\db\Query::limit方法的典型用法代码示例。如果您正苦于以下问题:PHP Query::limit方法的具体用法?PHP Query::limit怎么用?PHP Query::limit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yii\db\Query的用法示例。


在下文中一共展示了Query::limit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getPopularVideos

 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();
 }
开发者ID:Akelcehg,项目名称:psycho,代码行数:9,代码来源:Videos.php

示例2: getPopularPosts

 public static function getPopularPosts()
 {
     $query = new Query();
     $query->select('article.*,(SELECT  COUNT(*) FROM article_comments WHERE   article.id = article_comments.article_id) as commentsCount');
     $query->from('article');
     $query->orderBy('commentsCount DESC');
     $query->limit('4');
     return $query->all();
 }
开发者ID:Akelcehg,项目名称:psycho,代码行数:9,代码来源:Article.php

示例3: getMostActive

 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();
 }
开发者ID:Akelcehg,项目名称:psycho,代码行数:9,代码来源:Profile.php

示例4: getHistory

 public function getHistory($chatId, $limit = 10)
 {
     $query = new Query();
     $query->select(['user_id', 'username', 'message', 'timestamp', 'avatar_16', 'avatar_32'])->from(self::tableName())->where(['chat_id' => $chatId]);
     $query->orderBy(['timestamp' => SORT_DESC]);
     if ($limit) {
         $query->limit($limit);
     }
     return $query->all();
 }
开发者ID:Tatiana96,项目名称:justchat,代码行数:10,代码来源:DbStorage.php

示例5: getUserList

 /**
  * Returns list of users' full names
  * @param int $limit records count
  * @return array list of users' names
  */
 public static function getUserList($limit = null)
 {
     $query = new Query();
     $query->select(['id', 'text' => "CONCAT(`u`.`first_name`,' ', `u`.`last_name`)"])->from(['u' => 'User']);
     if (isset($limit)) {
         $query->limit($limit);
     }
     $query->each();
     $command = $query->createCommand();
     return $command->queryAll();
 }
开发者ID:vfokov,项目名称:tims2,代码行数:16,代码来源:User.php

示例6: getTopPsychologists

 public function getTopPsychologists($amount = null)
 {
     $query = new Query();
     $query->select('profile.*')->from('profile')->join('join', 'psychologist_top', 'psychologist_top.psychologist_id = profile.user_id')->orderBy('profile.id');
     if ($amount) {
         $query->limit($amount);
         return $psychologistsTopDataProvider = new ActiveDataProvider(['query' => $query]);
         //return $query->all();
     }
     return $psychologistsTopDataProvider = new ActiveDataProvider(['query' => $query]);
 }
开发者ID:Akelcehg,项目名称:psycho,代码行数:11,代码来源:PsychologistTop.php

示例7: getWhere

 private function getWhere($filters = [], $select = '*')
 {
     $query = new Query();
     $query->select($select)->from(static::tableName());
     if (isset($filters['offset']) && $filters['offset']) {
         $query->offset($filters['offset']);
     }
     if (isset($filters['limit']) && $filters['limit']) {
         $query->limit($filters['limit']);
     }
     return $query;
 }
开发者ID:huylv-hust,项目名称:ws,代码行数:12,代码来源:Sdptm01sagyo.php

示例8: GetItems

 /**
  * Получает записи с базы данных
  * @param string $where
  * @param string $column
  */
 public function GetItems($columns = [], $where = [], $limit = 0)
 {
     $query = new Query();
     $query->select($columns);
     $query->from($this->table);
     if ($where) {
         $query->where($where);
     }
     if ($limit) {
         $query->limit($limit);
     }
     $result = $query->all();
     return $result;
 }
开发者ID:developer-home,项目名称:project777,代码行数:19,代码来源:Model.php

示例9: getWhere

 private function getWhere($filters = [], $select = '*')
 {
     $query = new Query();
     $query->select($select)->from(static::tableName());
     if (isset($filters['D05_DEN_NO']) && $filters['D05_DEN_NO']) {
         $query->andwhere('D05_DEN_NO=:den_no', [':den_no' => $filters['D05_DEN_NO']]);
     }
     if (isset($filters['offset']) && $filters['offset']) {
         $query->offset($filters['offset']);
     }
     if (isset($filters['limit']) && $filters['limit']) {
         $query->limit($filters['limit']);
     }
     return $query;
 }
开发者ID:huylv-hust,项目名称:ws,代码行数:15,代码来源:Sdptd05denpyocom.php

示例10: run

 /**
  * @return array
  * @throws yii\web\NotFoundHttpException
  */
 public function run()
 {
     if (!isset($_GET[$this->query_variable])) {
         throw new yii\web\NotFoundHttpException();
     }
     $modelName = $this->modelName;
     Yii::$app->response->format = yii\web\Response::FORMAT_JSON;
     $query = new yii\db\Query();
     $query->select($this->json_attributes)->from($modelName::tableName());
     $search_query = $_GET[$this->query_variable];
     foreach ($this->search_attributes as $attribute) {
         $query->orWhere(['like', $attribute, $search_query]);
     }
     $suggest = $query->limit($this->limit)->all();
     return $suggest;
 }
开发者ID:tqsq2005,项目名称:dotplant2,代码行数:20,代码来源:AutocompleteAction.php

示例11: getWhere

 private function getWhere($filters = [], $select = '*')
 {
     $query = new Query();
     $query->select($select)->from(static::tableName());
     if (count($filters)) {
         foreach ($filters as $field => $val) {
             if ($field != 'offset' && $field != 'limit') {
                 $query->andwhere($field . ' = ' . $val);
             }
         }
     }
     //$query->where('status=:status', [':status' => $status]);
     if (isset($filters['offset']) && $filters['offset']) {
         $query->offset($filters['offset']);
     }
     if (isset($filters['limit']) && $filters['limit']) {
         $query->limit($filters['limit']);
     }
     return $query;
 }
开发者ID:huylv-hust,项目名称:ws,代码行数:20,代码来源:Sdptm03largecom.php

示例12: getWhere

 /**
  * @param array $filters
  * @param string $select
  * @return Query
  */
 private function getWhere($filters = [], $select = '*')
 {
     $query = new Query();
     $query->select($select)->from(static::tableName());
     if (isset($filters['M08_HAN_CD']) && $filters['M08_HAN_CD']) {
         $query->where('M08_HAN_CD=:han_cd', [':han_cd' => $filters['M08_HAN_CD']]);
     }
     if (isset($filters['M08_SS_CD']) && $filters['M08_SS_CD']) {
         $query->where('M08_SS_CD=:ss_cd', [':ss_cd' => $filters['M08_SS_CD']]);
     }
     if (isset($filters['M08_JYUG_CD']) && $filters['M08_JYUG_CD']) {
         $query->where('M08_JYUG_CD=:jy_cd', [':jy_cd' => $filters['M08_JYUG_CD']]);
     }
     if (isset($filters['offset']) && $filters['offset']) {
         $query->offset($filters['offset']);
     }
     if (isset($filters['limit']) && $filters['limit']) {
         $query->limit($filters['limit']);
     }
     return $query;
 }
开发者ID:huylv-hust,项目名称:ws,代码行数:26,代码来源:Sdptm08sagyosya.php

示例13: actionIndex

 /**
  * Lists all UrQuestions models.
  * @return mixed
  */
 public function actionIndex()
 {
     //топ аптек
     $db = new Query();
     $db->from('ur_questions');
     $db->select(['COUNT(*) AS count', 'ur_l_id', 'ur_l.name']);
     $db->leftJoin('ur_l', "ur_l.id=ur_questions.`ur_l_id`");
     $db->groupBy('ur_l_id');
     $db->orderBy('count DESC');
     $db->limit(5);
     $top = $db->all();
     $query = (new \yii\db\Query())->from('ur_questions');
     $query->select('username,ur_questions.id,ur_questions.created_at,question,ur_l.name,date_ansver');
     $query->leftJoin('ur_l', 'ur_questions.ur_l_id = ur_l.id');
     $query->leftJoin('users', 'ur_questions.user_id = users.id');
     if (\Yii::$app->user->identity->status != 1) {
         // $query->where(['ur_questions.user_id'=>\Yii::$app->user->identity->id]);
     }
     $query->orderBy(['ur_questions.id' => SORT_DESC]);
     $dataProvider = new ActiveDataProvider(['key' => 'id', 'query' => $query->from('ur_questions')]);
     return $this->render('index', ['dataProvider' => $dataProvider, 'top' => $top]);
 }
开发者ID:pumi11,项目名称:aau,代码行数:26,代码来源:UrquestionsController.php

示例14: getWhere

 private function getWhere($filters = [], $select = '*')
 {
     $query = new Query();
     $query->select($select)->from(static::tableName());
     //$query->where('status=:status', [':status' => $status]);
     if (isset($filters['D01_KAIIN_CD']) && $filters['D01_KAIIN_CD']) {
         $query->andwhere('D01_KAIIN_CD = ' . $filters['D01_KAIIN_CD']);
     }
     if (isset($filters['D01_CUST_NO']) && $filters['D01_CUST_NO']) {
         $query->andwhere('D01_CUST_NO = ' . $filters['D01_CUST_NO']);
     }
     if (isset($filters['D01_KAKE_CARD_NO']) && $filters['D01_KAKE_CARD_NO']) {
         $query->where(['D01_KAKE_CARD_NO' => $filters['D01_KAKE_CARD_NO']]);
     }
     if (isset($filters['offset']) && $filters['offset']) {
         $query->offset($filters['offset']);
     }
     if (isset($filters['limit']) && $filters['limit']) {
         $query->limit($filters['limit']);
     }
     return $query;
 }
开发者ID:huylv-hust,项目名称:ws,代码行数:22,代码来源:Sdptd01customer.php

示例15: getList

 public static function getList($page = 1, $rows = 10, $condition = '', $conditionParams = [])
 {
     $return = [];
     $query = new Query();
     $query->select('COUNT(1)');
     $query->from(self::tableName() . ' t0');
     $query->where($condition, $conditionParams);
     $result['total'] = $query->scalar();
     $query->select(['t0.id', 't0.username', 't0.email', 't1.firstname', 't1.lastname']);
     $query->join('LEFT JOIN', 'user_profile t1', 't0.id = t1.user_id');
     $query->offset($page * $rows - $rows);
     $query->limit($rows);
     $result['rows'] = $query->All();
     foreach ($result['rows'] as $k => $v) {
         $myRoles = Yii::$app->authManager->getRolesByUser($v['id']);
         if (count($myRoles)) {
             foreach ($myRoles as $kk => $vv) {
                 $result['rows'][$k]['role'] = $kk;
                 break;
             }
         }
     }
     return $result;
 }
开发者ID:sheillendra,项目名称:yii2-user,代码行数:24,代码来源:UserCrud.php


注:本文中的yii\db\Query::limit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。