예제 #1
0
 public function search($params)
 {
     $query = SqlLogSearch::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->setSort(['attributes' => ['sqlusedtime']]);
     $this->load($params);
     if (!$this->validate()) {
         return $dataProvider;
     }
     if (isset($params['id'])) {
         $query->andWhere(['Id' => $params['id']]);
     }
     if (isset($params['SqlLogSearch']['start_date']) && !empty($params['SqlLogSearch']['start_date'])) {
         $query->andWhere(" executedate>=:start_date", [':start_date' => $params['SqlLogSearch']['start_date']]);
     }
     if (isset($params['SqlLogSearch']['end_date']) && !empty($params['SqlLogSearch']['end_date'])) {
         $query->andWhere(" executedate<=:end_date", [':end_date' => $params['SqlLogSearch']['end_date']]);
     }
     if (isset($params['SqlLogSearch']['sqltext']) && !empty($params['SqlLogSearch']['sqltext'])) {
         $query->andWhere(['like', 'sqltext', $params['SqlLogSearch']['sqltext']]);
     }
     if (!isset($params['sort'])) {
         $query->orderBy('executedate desc ');
     }
     return $dataProvider;
 }
예제 #2
0
 /**
  * 首页信息
  * @return type
  */
 public function actionIndex()
 {
     $params = Yii::$app->request->get();
     $searchModel = new SqlLogSearch();
     $dataProvider = $searchModel->search($params);
     $query = $dataProvider->query;
     $sort = new Sort(['attributes' => ['executedate'], 'defaultOrder' => ['executedate' => SORT_DESC]]);
     $locals = ToolService::getPagedRows($query, $tablename = 'SqlTrace', $params, ['orderBy' => $sort->orders, 'pageSize' => 30]);
     $locals['searchModel'] = $searchModel;
     return $this->render('sql', $locals);
 }
예제 #3
0
파일: sql.php 프로젝트: wuxing164/tuanlogs
<?php

/* @var $this yii\web\View */
use backend\models\SqlLogSearch;
use yii\grid\GridView;
use yii\widgets\Pjax;
use yii\helpers\Html;
use yii\widgets\Breadcrumbs;
$this->title = '日志列表';
#获得日志统计记录
$params = \Yii::$app->request->queryParams;
$searchModel = new SqlLogSearch();
$dataProvider = $searchModel->search($params);
?>
<div class="site-index">
    <?php 
echo Breadcrumbs::widget(['itemTemplate' => "<li><i>{link}</i></li>\n", 'links' => [['label' => '首页']]]);
?>

    <div class="body-content">
        <div class="panel panel-default">
            <?php 
echo $this->render('common_top.php');
?>
            <div class="panel-body">
                <?php 
Pjax::begin(['id' => 'countries']);
?>
                <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn', 'headerOptions' => ['style' => 'width:80px;']], ['label' => '语句', 'filter' => Html::activeTextInput($searchModel, 'sqltext', ['class' => 'form-control']), 'format' => 'raw', 'value' => function ($model) {
    return '<div class="well">' . Html::encode($model->sqltext) . '</div>';