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


PHP Query::GroupBy方法代码示例

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


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

示例1: actionEmptyregional

 public function actionEmptyregional()
 {
     $db = new Query();
     $db->from('ur_l');
     $db->select(['ur_l.name', 'ur_l.id', 'GROUP_CONCAT(region.name) as rname']);
     $db->InnerJoin('region_ur_l', 'region_ur_l.id_ur = ur_l.id');
     $db->InnerJoin('region', 'region_ur_l.id_reg = region.id');
     //$db->andWhere(['like', 'log_reestr.created_at', $date]);
     $db->GroupBy('ur_l.id');
     $db->orderBy('rname', 'ur_l.name');
     $data = $db->all();
     return $this->render('empty', ['data' => $data]);
 }
开发者ID:pumi11,项目名称:aau,代码行数:13,代码来源:StatsController.php

示例2: All_excel

 public static function All_excel($select, $where, $groupby, $count)
 {
     $db = new Query();
     $db->from('apteki');
     $select[] = 'ur_l.inn as inn2';
     $select[] = 'ur_l.id as id2';
     $select[] = 'region.id as rid';
     $db->select($select);
     $db->LeftJoin('ur_l', 'apteki.ur_l_id = ur_l.id');
     //$db->Where('=', 'region.id',$where[region]);
     if ($where['region']) {
         $db->andWhere(['=', 'region.id', $where['region']]);
     }
     if ($where['regional']) {
         $db->andWhere(['=', 'users.id', $where['regional']]);
     }
     if ($groupby['ur_l.id']) {
         $db->InnerJoin('region_ur_l', 'region_ur_l.id_ur = ur_l.id');
         $db->InnerJoin('region', 'region_ur_l.id_reg = region.id');
         $db->InnerJoin('ur_l as u2', 'ur_l.id=region_ur_l.id_ur');
         $db->GroupBy('ur_l.id');
     }
     if (!$groupby['ur_l.id']) {
         $db->LeftJoin('region', 'apteki.region_id = region.id');
     }
     //регионы Юр.лиц
     //$db->InnerJoin('region_ur_l', 'region_ur_l.id_ur = ur_l.id');
     //$db->InnerJoin('region', 'region_ur_l.id_reg = region.id');
     $db->LeftJoin('users', 'apteki.regional_id = users.id');
     $db->LeftJoin('view_pi', 'apteki.pi_id = view_pi.id');
     $db->LeftJoin('sb_site_users', 'sb_site_users.ur_l_id = ur_l.id');
     // $db->GroupBy('apteki.id');
     //  $db->orderBy('region.name','ur_l.name','apteki.name');
     $db->orderBy(['region.name' => SORT_ASC, 'ur_l.name' => SORT_ASC]);
     $data = $db->all();
     $countAll = $db->count();
     for ($i = 0; $i < count($data); $i++) {
         /*
         $count = (new Query())
             ->from('apteki')
             ->where(['ur_l_id' => $data[$i]['id2']])
             ->count();
         */
         if ($data[$i]['ur_l__farmopeka']) {
             $data[$i]['ur_l__farmopeka'] = "Да";
         } else {
             $data[$i]['ur_l__farmopeka'] = "Нет";
         }
         if ($data[$i]['apteki__farmopeka']) {
             $data[$i]['apteki__farmopeka'] = "Да";
         } else {
             $data[$i]['apteki__farmopeka'] = "Нет";
         }
         if ($data[$i]['ur_l__plat']) {
             $data[$i]['ur_l__plat'] = "Да";
         } else {
             $data[$i]['ur_l__plat'] = "Нет";
         }
         if ($count['apteki']) {
             $count2 = new Query();
             $count2->from('apteki');
             $count2->where(['ur_l_id' => $data[$i]['id2']]);
             $count2->andWhere(['apteki.region_id' => $data[$i]['rid']]);
             if (!isset($temp)) {
                 $temp = "";
             }
             if ($temp != $data[$i]['rid'] . $data[$i]['id2']) {
                 $counts = $count2->count();
                 $data[$i]['apteki'] = $counts;
                 $no = 1;
             } else {
                 $data[$i]['apteki'] = "";
                 $data[$i]['ur_l'] = "";
                 $no = 2;
             }
             $temp = $data[$i]['rid'] . $data[$i]['id2'];
         }
         if ($no == 1) {
             if ($count['ur_l']) {
                 $count2 = new Query();
                 $count2->from('ur_l');
                 $count2->where(['inn' => $data[$i]['inn2']]);
                 $counts = $count2->count();
                 $data[$i]['ur_l'] = $counts;
             }
             $data[$i]['count'] = $countAll;
         }
     }
     return $data;
 }
开发者ID:pumi11,项目名称:aau,代码行数:90,代码来源:MyJson.php


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