public function view() { $projectDB = new ProjectModelDB(); //普通条件,检查GET参数 $fieldArr = $projectDB->getFields(); $where = array("`group_id` = ?"); $whereArr = array($_SESSION['group']); foreach ($fieldArr as $v) { if ($_GET[$v] !== null) { $where[] = "`{$v}` = ?"; $whereArr[] = $_GET[$v]; } } $whereStr = count($where) > 0 ? implode(" AND ", $where) : '1=1'; if ($_GET['_search_field'] != '' && in_array($_GET['_search_field'], $fieldArr) && $_GET['_search_keyword'] != '') { $whereStr = $whereStr == '1=1' ? $_GET['_search_field'] . " LIKE ?" : $whereStr . " AND " . $_GET['_search_field'] . " LIKE ?"; $whereArr[] = "%" . $_GET['_search_keyword'] . "%"; } //排序条件 $orderStr = '`id` DESC'; if (!empty($_POST['order'])) { foreach ($_POST['order'] as $k => $v) { $orderArr[] = "`{$k}` {$v}"; } $orderStr = implode(',', $orderArr); } //查询操作 $sql = "SELECT * FROM `" . $projectDB->getTableName() . "` WHERE {$whereStr} ORDER BY {$orderStr}"; $data = $projectDB->getData($sql, $whereArr, 80); $pageStr = $projectDB->getPageStr(); $pageJump = $projectDB->getPageJump(); //读取外键数据 $project = new ProjectModel(); $monitorFkArr = $project->getMonitor(); $this->setView('monitorFkArr', $monitorFkArr); $onoffArrDictFkArr = DictConfig::$onoffArr; $this->setView('onoffArrDictFkArr', $onoffArrDictFkArr); //模版显示 $this->setView('commonConfig', $this->commonConfig); $this->setView('svnUrl', $this->svnUrl); $this->setView('pageStr', $pageStr); $this->setView('pageStr', $pageStr); $this->setView('pageJump', $pageJump); $this->setView('data', $data); $this->display('Project.html'); }