Esempio n. 1
0
                                                    <?php 
echo $form->field($hbasevisit, 'key_word')->textInput(['class' => 'form-control']);
?>
                                                    <button style="margin-bottom: 10px;" type="submit" class="btn btn-default btn-primary btn-sm">查询</button>
                                                </div>
                                            </div>
                                        </div> 
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div class="content form-inline">
                                            <div class="row">
                                                <div class="col-md-12">
                                                    <?php 
echo $form->field($hbasevisit, 'show_check')->checkboxList(HbaseVisitForm::showlist());
?>
                                                </div>
                                            </div>
                                        </div> 
                                    </td>
                                </tr>
                                <?php 
ActiveForm::end();
?>
                            </tbody>
                        </table>
                    </div>
                    <div class="panel-body">
                        <table class="table table-striped table-bordered">
                            <?php 
Esempio n. 2
0
 /**
  * 获得指定范围条件查询数据
  */
 public static function findDataLists()
 {
     //获得查询的信息
     $tablename = '';
     $showCols = [];
     $searchFit = \Yii::$app->request->get();
     $filter = '';
     if (isset($searchFit['HbaseVisitForm'])) {
         //配置tablename
         $partone = $searchFit['HbaseVisitForm']['proxy'];
         $partTwo = Date("Ymd", strtotime($searchFit['HbaseVisitForm']['start_time']));
         $tablename = $partone . $partTwo;
         //处理要显示的信息
         foreach ($searchFit['HbaseVisitForm']['show_check'] as $oneSelect) {
             $showCols[] = 'info:' . $oneSelect;
         }
         $keyword = trim($searchFit['HbaseVisitForm']['key_word']);
         if (!empty($keyword)) {
             if ($searchFit['HbaseVisitForm']['search_col'] = 'ip') {
                 $keyword = str_replace(".", "\\.", $keyword);
             }
             $filter = "SingleColumnValueFilter('info','{$searchFit['HbaseVisitForm']['search_col']}',=,'regexstring:.*125\\.84\\.84\\.187.*')";
         }
     } else {
         $searchFit['HbaseVisitForm'] = [];
         //默认显示当天nginx日志的内容
         //开始配置查询内容
         //$tablename='nginx'.date('Ymd');
         $tablename = 'nginx20160713';
         //默认显示数据
         //增加查询条件
         $showCols = ['info:country', 'info:province', 'info:city', 'info:ip', 'info:request_url', 'info:datereg'];
     }
     //获得查询的KEY值范围
     list($page, $mdKey, $startKey, $endKey) = self::returnSearchKey($tablename, $searchFit);
     $client = self::getClient();
     self::$transport->open();
     //创建一个查询模型
     $scan = new \Hbase\TScan();
     $scan->startRow = $startKey;
     $scan->stopRow = $endKey;
     $scan->columns = $showCols;
     $scan->caching = 1000;
     if (!empty($filter)) {
         $scan->filterString = $filter;
     }
     //$scan->filterString="RowFilter(=, 'regexstring:0001000002000018')";
     //$scan->filterString="RowFilter(=, '0001000002000018')";
     //$scan->filterString = "SingleColumnValueFilter('info','country',=,'binary:中国')";
     $scanner = $client->scannerOpenWithScan("nginx20160713", $scan, []);
     $get_arr = $client->scannerGetList($scanner, 20);
     self::$transport->close();
     if (!$get_arr) {
         return [];
     }
     //处理th描述
     $chineseWord = \backend\models\forms\HbaseVisitForm::showlist();
     $thData = [];
     //循环处理第一个数组的数据,得到TH内容
     foreach ($get_arr[0]->columns as $key => $indexOneDate) {
         $newKey1 = explode(':', $key);
         $newKey = $newKey1[1];
         $thData[] = $chineseWord[$newKey];
     }
     //存储分页
     $dateEndnum = count($get_arr);
     $filePage[$page]['start'] = $get_arr[0]->row;
     $filePage[$page]['end'] = $get_arr[$dateEndnum - 1]->row;
     \Yii::$app->cache->set($mdKey, $dateEndnum);
     //获得查询的串生成MDKEY
     return ['th' => $thData, 'data' => $get_arr, 'page' => $page];
 }