• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP zbx_ctype_digit函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中zbx_ctype_digit函数的典型用法代码示例。如果您正苦于以下问题:PHP zbx_ctype_digit函数的具体用法?PHP zbx_ctype_digit怎么用?PHP zbx_ctype_digit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: get

 /**
  * Get GraphItems data
  *
  * @param array $options
  * @return array|boolean
  */
 public function get($options = array())
 {
     $result = array();
     $userType = self::$userData['type'];
     $userid = self::$userData['userid'];
     $sqlParts = array('select' => array('gitems' => 'gi.gitemid'), 'from' => array('graphs_items' => 'graphs_items gi'), 'where' => array(), 'order' => array(), 'limit' => null);
     $defOptions = array('graphids' => null, 'itemids' => null, 'type' => null, 'editable' => null, 'nopermissions' => null, 'selectGraphs' => null, 'output' => API_OUTPUT_EXTEND, 'expandData' => null, 'countOutput' => null, 'preservekeys' => null, 'sortfield' => '', 'sortorder' => '', 'limit' => null);
     $options = zbx_array_merge($defOptions, $options);
     $this->checkDeprecatedParam($options, 'expandData');
     // editable + PERMISSION CHECK
     if ($userType != USER_TYPE_SUPER_ADMIN && !$options['nopermissions']) {
         $permission = $options['editable'] ? PERM_READ_WRITE : PERM_READ;
         $userGroups = getUserGroupsByUserId($userid);
         $sqlParts['where'][] = 'EXISTS (' . 'SELECT NULL' . ' FROM items i,hosts_groups hgg' . ' JOIN rights r' . ' ON r.id=hgg.groupid' . ' AND ' . dbConditionInt('r.groupid', $userGroups) . ' WHERE gi.itemid=i.itemid' . ' AND i.hostid=hgg.hostid' . ' GROUP BY i.itemid' . ' HAVING MIN(r.permission)>' . PERM_DENY . ' AND MAX(r.permission)>=' . zbx_dbstr($permission) . ')';
     }
     // graphids
     if (!is_null($options['graphids'])) {
         zbx_value2array($options['graphids']);
         $sqlParts['from']['graphs'] = 'graphs g';
         $sqlParts['where']['gig'] = 'gi.graphid=g.graphid';
         $sqlParts['where'][] = dbConditionInt('g.graphid', $options['graphids']);
     }
     // itemids
     if (!is_null($options['itemids'])) {
         zbx_value2array($options['itemids']);
         $sqlParts['where'][] = dbConditionInt('gi.itemid', $options['itemids']);
     }
     // type
     if (!is_null($options['type'])) {
         $sqlParts['where'][] = 'gi.type=' . zbx_dbstr($options['type']);
     }
     // limit
     if (zbx_ctype_digit($options['limit']) && $options['limit']) {
         $sqlParts['limit'] = $options['limit'];
     }
     $sqlParts = $this->applyQueryOutputOptions($this->tableName(), $this->tableAlias(), $options, $sqlParts);
     $sqlParts = $this->applyQuerySortOptions($this->tableName(), $this->tableAlias(), $options, $sqlParts);
     $dbRes = DBselect($this->createSelectQueryFromParts($sqlParts), $sqlParts['limit']);
     while ($gitem = DBfetch($dbRes)) {
         if (!is_null($options['countOutput'])) {
             $result = $gitem['rowscount'];
         } else {
             $result[$gitem['gitemid']] = $gitem;
         }
     }
     if (!is_null($options['countOutput'])) {
         return $result;
     }
     if ($result) {
         $result = $this->addRelatedObjects($options, $result);
         $result = $this->unsetExtraFields($result, array('graphid'), $options['output']);
     }
     // removing keys (hash -> array)
     if (is_null($options['preservekeys'])) {
         $result = zbx_cleanHashes($result);
     }
     return $result;
 }
开发者ID:TonywalkerCN,项目名称:Zabbix,代码行数:64,代码来源:CGraphItem.php


示例2: get

 /**
  * Get IconMap data.
  * @param array $options
  * @param array $options['iconmapids']
  * @param array $options['sysmapids']
  * @param array $options['editable']
  * @param array $options['count']
  * @param array $options['limit']
  * @param array $options['order']
  * @return array
  */
 public function get(array $options = [])
 {
     $result = [];
     $sqlParts = ['select' => ['icon_map' => 'im.iconmapid'], 'from' => ['icon_map' => 'icon_map im'], 'where' => [], 'order' => [], 'limit' => null];
     $defOptions = ['iconmapids' => null, 'sysmapids' => null, 'nopermissions' => null, 'editable' => null, 'filter' => null, 'search' => null, 'searchByAny' => null, 'startSearch' => null, 'excludeSearch' => null, 'searchWildcardsEnabled' => null, 'output' => API_OUTPUT_EXTEND, 'selectMappings' => null, 'countOutput' => null, 'preservekeys' => null, 'sortfield' => '', 'sortorder' => '', 'limit' => null];
     $options = zbx_array_merge($defOptions, $options);
     // editable + PERMISSION CHECK
     if ($options['editable'] && self::$userData['type'] != USER_TYPE_SUPER_ADMIN) {
         return [];
     }
     // iconmapids
     if (!is_null($options['iconmapids'])) {
         zbx_value2array($options['iconmapids']);
         $sqlParts['where'][] = dbConditionInt('im.iconmapid', $options['iconmapids']);
     }
     // sysmapids
     if (!is_null($options['sysmapids'])) {
         zbx_value2array($options['sysmapids']);
         $sqlParts['from']['sysmaps'] = 'sysmaps s';
         $sqlParts['where'][] = dbConditionInt('s.sysmapid', $options['sysmapids']);
         $sqlParts['where']['ims'] = 'im.iconmapid=s.iconmapid';
     }
     // filter
     if (is_array($options['filter'])) {
         $this->dbFilter('icon_map im', $options, $sqlParts);
     }
     // search
     if (is_array($options['search'])) {
         zbx_db_search('icon_map im', $options, $sqlParts);
     }
     // limit
     if (zbx_ctype_digit($options['limit']) && $options['limit']) {
         $sqlParts['limit'] = $options['limit'];
     }
     $sqlParts = $this->applyQueryOutputOptions($this->tableName(), $this->tableAlias(), $options, $sqlParts);
     $sqlParts = $this->applyQuerySortOptions($this->tableName(), $this->tableAlias(), $options, $sqlParts);
     $dbRes = DBselect($this->createSelectQueryFromParts($sqlParts), $sqlParts['limit']);
     while ($iconMap = DBfetch($dbRes)) {
         if ($options['countOutput']) {
             $result = $iconMap['rowscount'];
         } else {
             $result[$iconMap['iconmapid']] = $iconMap;
         }
     }
     if (!is_null($options['countOutput'])) {
         return $result;
     }
     if ($result) {
         $result = $this->addRelatedObjects($options, $result);
     }
     // removing keys (hash -> array)
     if (is_null($options['preservekeys'])) {
         $result = zbx_cleanHashes($result);
     }
     return $result;
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:67,代码来源:CIconMap.php


示例3: checkExpression

 public function checkExpression($expression)
 {
     $length = zbx_strlen($expression);
     $symbolNum = 0;
     try {
         if (zbx_empty(trim($expression))) {
             throw new Exception('Empty expression.');
         }
         // Check expr start symbol
         $startSymbol = zbx_substr(trim($expression), 0, 1);
         if ($startSymbol != '(' && $startSymbol != '{' && $startSymbol != '-' && !zbx_ctype_digit($startSymbol)) {
             throw new Exception('Incorrect trigger expression.');
         }
         for ($symbolNum = 0; $symbolNum < $length; $symbolNum++) {
             $symbol = zbx_substr($expression, $symbolNum, 1);
             // SDI($symbol);
             $this->parseOpenParts($this->previous['last']);
             $this->parseCloseParts($symbol);
             // SDII($this->currExpr);
             if ($this->inParameter($symbol)) {
                 $this->setPreviousSymbol($symbol);
                 continue;
             }
             $this->checkSymbolSequence($symbol);
             $this->setPreviousSymbol($symbol);
             // SDII($this->symbols);
         }
         $symbolNum = 0;
         $simpleExpression = $expression;
         $this->checkBraces();
         $this->checkParts($simpleExpression);
         $this->checkSimpleExpression($simpleExpression);
     } catch (Exception $e) {
         $symbolNum = $symbolNum > 0 ? --$symbolNum : $symbolNum;
         $this->errors[] = $e->getMessage();
         $this->errors[] = 'Check expression part starting from " ' . zbx_substr($expression, $symbolNum) . ' "';
     }
 }
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:38,代码来源:class.ctriggerexpression.php


示例4: get

 /**
  * Get data about web scenarios.
  *
  * @param array $options
  *
  * @return array
  */
 public function get($options = array())
 {
     $result = array();
     $userType = self::$userData['type'];
     $userid = self::$userData['userid'];
     // allowed columns for sorting
     $sortColumns = array('httptestid', 'name');
     // allowed output options for [ select_* ] params
     $subselectsAllowedOutputs = array(API_OUTPUT_REFER, API_OUTPUT_EXTEND);
     $sqlParts = array('select' => array('httptests' => 'ht.httptestid'), 'from' => array('httptest' => 'httptest ht'), 'where' => array(), 'group' => array(), 'order' => array(), 'limit' => null);
     $defOptions = array('nodeids' => null, 'httptestids' => null, 'applicationids' => null, 'hostids' => null, 'editable' => null, 'nopermissions' => null, 'filter' => null, 'search' => null, 'searchByAny' => null, 'startSearch' => null, 'exludeSearch' => null, 'output' => API_OUTPUT_REFER, 'selectHosts' => null, 'selectSteps' => null, 'countOutput' => null, 'groupCount' => null, 'preservekeys' => null, 'sortfield' => '', 'sortorder' => '', 'limit' => null);
     $options = zbx_array_merge($defOptions, $options);
     // editable + PERMISSION CHECK
     if ($userType != USER_TYPE_SUPER_ADMIN && !$options['nopermissions']) {
         $permission = $options['editable'] ? PERM_READ_WRITE : PERM_READ_ONLY;
         $userGroups = getUserGroupsByUserId($userid);
         $sqlParts['where'][] = 'EXISTS (' . 'SELECT NULL' . ' FROM applications a,hosts_groups hgg' . ' JOIN rights r' . ' ON r.id=hgg.groupid' . ' AND ' . dbConditionInt('r.groupid', $userGroups) . ' WHERE a.applicationid=ht.applicationid' . ' AND a.hostid=hgg.hostid' . ' GROUP BY a.applicationid' . ' HAVING MIN(r.permission)>=' . $permission . ')';
     }
     // nodeids
     $nodeids = !is_null($options['nodeids']) ? $options['nodeids'] : get_current_nodeid();
     // httptestids
     if (!is_null($options['httptestids'])) {
         zbx_value2array($options['httptestids']);
         if ($options['output'] != API_OUTPUT_SHORTEN) {
             $sqlParts['select']['httptestid'] = 'ht.httptestid';
         }
         $sqlParts['where']['httptestid'] = dbConditionInt('ht.httptestid', $options['httptestids']);
     }
     // hostids
     if (!is_null($options['hostids'])) {
         zbx_value2array($options['hostids']);
         if ($options['output'] != API_OUTPUT_SHORTEN) {
             $sqlParts['select']['hostid'] = 'a.hostid';
         }
         $sqlParts['from']['applications'] = 'applications a';
         $sqlParts['where'][] = 'a.applicationid=ht.applicationid';
         $sqlParts['where']['hostid'] = dbConditionInt('a.hostid', $options['hostids']);
         if (!is_null($options['groupCount'])) {
             $sqlParts['group']['hostid'] = 'a.hostid';
         }
     }
     // applicationids
     if (!is_null($options['applicationids'])) {
         zbx_value2array($options['applicationids']);
         if ($options['output'] != API_OUTPUT_EXTEND) {
             $sqlParts['select']['applicationid'] = 'a.applicationid';
         }
         $sqlParts['where'][] = dbConditionInt('ht.applicationid', $options['applicationids']);
     }
     // output
     if ($options['output'] == API_OUTPUT_EXTEND) {
         $sqlParts['select']['httptests'] = 'ht.*';
     }
     // countOutput
     if (!is_null($options['countOutput'])) {
         $options['sortfield'] = '';
         $sqlParts['select'] = array('count(ht.httptestid) as rowscount');
         // groupCount
         if (!is_null($options['groupCount'])) {
             foreach ($sqlParts['group'] as $key => $fields) {
                 $sqlParts['select'][$key] = $fields;
             }
         }
     }
     // search
     if (is_array($options['search'])) {
         zbx_db_search('httptest ht', $options, $sqlParts);
     }
     // filter
     if (is_array($options['filter'])) {
         $this->dbFilter('httptest ht', $options, $sqlParts);
     }
     // sorting
     zbx_db_sorting($sqlParts, $options, $sortColumns, 'ht');
     // limit
     if (zbx_ctype_digit($options['limit']) && $options['limit']) {
         $sqlParts['limit'] = $options['limit'];
     }
     $httpTestIds = array();
     $sqlParts['select'] = array_unique($sqlParts['select']);
     $sqlParts['from'] = array_unique($sqlParts['from']);
     $sqlParts['where'] = array_unique($sqlParts['where']);
     $sqlParts['group'] = array_unique($sqlParts['group']);
     $sqlParts['order'] = array_unique($sqlParts['order']);
     $sqlSelect = '';
     $sqlFrom = '';
     $sqlWhere = '';
     $sqlGroup = '';
     $sqlOrder = '';
     if (!empty($sqlParts['select'])) {
         $sqlSelect .= implode(',', $sqlParts['select']);
     }
     if (!empty($sqlParts['from'])) {
//.........这里部分代码省略.........
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:101,代码来源:CWebCheck.php


示例5: get

 public function get($options)
 {
     $result = array();
     $userType = self::$userData['type'];
     $sqlParts = array('select' => array('dchecks' => 'dc.dcheckid'), 'from' => array('dchecks' => 'dchecks dc'), 'where' => array(), 'group' => array(), 'order' => array(), 'limit' => null);
     $defOptions = array('dcheckids' => null, 'druleids' => null, 'dserviceids' => null, 'editable' => null, 'nopermissions' => null, 'filter' => null, 'search' => null, 'searchByAny' => null, 'startSearch' => null, 'excludeSearch' => null, 'searchWildcardsEnabled' => null, 'output' => API_OUTPUT_EXTEND, 'selectDRules' => null, 'countOutput' => null, 'groupCount' => null, 'preservekeys' => null, 'sortfield' => '', 'sortorder' => '', 'limit' => null, 'limitSelects' => null);
     $options = zbx_array_merge($defOptions, $options);
     // editable + PERMISSION CHECK
     if (USER_TYPE_SUPER_ADMIN == $userType) {
     } elseif (is_null($options['editable']) && self::$userData['type'] == USER_TYPE_ZABBIX_ADMIN) {
     } elseif (!is_null($options['editable']) && self::$userData['type'] != USER_TYPE_SUPER_ADMIN) {
         return array();
     }
     // dcheckids
     if (!is_null($options['dcheckids'])) {
         zbx_value2array($options['dcheckids']);
         $sqlParts['where']['dcheckid'] = dbConditionInt('dc.dcheckid', $options['dcheckids']);
     }
     // druleids
     if (!is_null($options['druleids'])) {
         zbx_value2array($options['druleids']);
         $sqlParts['where'][] = dbConditionInt('dc.druleid', $options['druleids']);
         if (!is_null($options['groupCount'])) {
             $sqlParts['group']['druleid'] = 'dc.druleid';
         }
     }
     // dserviceids
     if (!is_null($options['dserviceids'])) {
         zbx_value2array($options['dserviceids']);
         $sqlParts['from']['dhosts'] = 'dhosts dh';
         $sqlParts['from']['dservices'] = 'dservices ds';
         $sqlParts['where']['ds'] = dbConditionInt('ds.dserviceid', $options['dserviceids']);
         $sqlParts['where']['dcdh'] = 'dc.druleid=dh.druleid';
         $sqlParts['where']['dhds'] = 'dh.hostid=ds.hostid';
         if (!is_null($options['groupCount'])) {
             $sqlParts['group']['dserviceid'] = 'ds.dserviceid';
         }
     }
     // filter
     if (is_array($options['filter'])) {
         $this->dbFilter('dchecks dc', $options, $sqlParts);
     }
     // search
     if (is_array($options['search'])) {
         zbx_db_search('dchecks dc', $options, $sqlParts);
     }
     // limit
     if (zbx_ctype_digit($options['limit']) && $options['limit']) {
         $sqlParts['limit'] = $options['limit'];
     }
     //-------
     $sqlParts = $this->applyQueryOutputOptions($this->tableName(), $this->tableAlias(), $options, $sqlParts);
     $sqlParts = $this->applyQuerySortOptions($this->tableName(), $this->tableAlias(), $options, $sqlParts);
     $res = DBselect($this->createSelectQueryFromParts($sqlParts), $sqlParts['limit']);
     while ($dcheck = DBfetch($res)) {
         if (!is_null($options['countOutput'])) {
             if (!is_null($options['groupCount'])) {
                 $result[] = $dcheck;
             } else {
                 $result = $dcheck['rowscount'];
             }
         } else {
             $result[$dcheck['dcheckid']] = $dcheck;
         }
     }
     if (!is_null($options['countOutput'])) {
         return $result;
     }
     if ($result) {
         $result = $this->addRelatedObjects($options, $result);
         $result = $this->unsetExtraFields($result, array('druleid'), $options['output']);
     }
     // removing keys (hash -> array)
     if (is_null($options['preservekeys'])) {
         $result = zbx_cleanHashes($result);
     }
     return $result;
 }
开发者ID:TonywalkerCN,项目名称:Zabbix,代码行数:78,代码来源:CDCheck.php


示例6: get


//.........这里部分代码省略.........
     }
     // node check !!!!!
     // should last, after all ****IDS checks
     if (!$nodeCheck) {
         $nodeCheck = true;
         $sqlParts['where'][] = DBin_node('ds.dserviceid', $nodeids);
     }
     // output
     if ($options['output'] == API_OUTPUT_EXTEND) {
         $sqlParts['select']['dservices'] = 'ds.*';
     }
     // countOutput
     if (!is_null($options['countOutput'])) {
         $options['sortfield'] = '';
         $sqlParts['select'] = array('count(DISTINCT ds.dserviceid) as rowscount');
         //groupCount
         if (!is_null($options['groupCount'])) {
             foreach ($sqlParts['group'] as $key => $fields) {
                 $sqlParts['select'][$key] = $fields;
             }
         }
     }
     // filter
     if (is_array($options['filter'])) {
         $this->dbFilter('dservices ds', $options, $sqlParts);
     }
     // search
     if (is_array($options['search'])) {
         zbx_db_search('dservices ds', $options, $sqlParts);
     }
     // sorting
     zbx_db_sorting($sqlParts, $options, $sortColumns, 'ds');
     // limit
     if (zbx_ctype_digit($options['limit']) && $options['limit']) {
         $sqlParts['limit'] = $options['limit'];
     }
     //-------
     $dserviceids = array();
     $sqlParts['select'] = array_unique($sqlParts['select']);
     $sqlParts['from'] = array_unique($sqlParts['from']);
     $sqlParts['where'] = array_unique($sqlParts['where']);
     $sqlParts['group'] = array_unique($sqlParts['group']);
     $sqlParts['order'] = array_unique($sqlParts['order']);
     $sqlSelect = '';
     $sqlFrom = '';
     $sqlWhere = '';
     $sqlGroup = '';
     $sqlOrder = '';
     if (!empty($sqlParts['select'])) {
         $sqlSelect .= implode(',', $sqlParts['select']);
     }
     if (!empty($sqlParts['from'])) {
         $sqlFrom .= implode(',', $sqlParts['from']);
     }
     if (!empty($sqlParts['where'])) {
         $sqlWhere .= implode(' AND ', $sqlParts['where']);
     }
     if (!empty($sqlParts['group'])) {
         $sqlWhere .= ' GROUP BY ' . implode(',', $sqlParts['group']);
     }
     if (!empty($sqlParts['order'])) {
         $sqlOrder .= ' ORDER BY ' . implode(',', $sqlParts['order']);
     }
     $sqlLimit = $sqlParts['limit'];
     $sql = 'SELECT ' . zbx_db_distinct($sqlParts) . ' ' . $sqlSelect . ' FROM ' . $sqlFrom . ' WHERE ' . $sqlWhere . $sqlGroup . $sqlOrder;
     //SDI($sql);
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:67,代码来源:CDService.php


示例7: get

 /**
  * Get scripts data.
  *
  * @param array  $options
  * @param array  $options['itemids']
  * @param array  $options['hostids']	deprecated (very slow)
  * @param array  $options['groupids']
  * @param array  $options['triggerids']
  * @param array  $options['scriptids']
  * @param bool   $options['status']
  * @param bool   $options['editable']
  * @param bool   $options['count']
  * @param string $options['pattern']
  * @param int    $options['limit']
  * @param string $options['order']
  *
  * @return array
  */
 public function get(array $options)
 {
     $result = array();
     $userType = self::$userData['type'];
     $userid = self::$userData['userid'];
     $sqlParts = array('select' => array('scripts' => 's.scriptid'), 'from' => array('scripts s'), 'where' => array(), 'order' => array(), 'limit' => null);
     $defOptions = array('groupids' => null, 'hostids' => null, 'scriptids' => null, 'usrgrpids' => null, 'editable' => null, 'nopermissions' => null, 'filter' => null, 'search' => null, 'searchByAny' => null, 'startSearch' => null, 'excludeSearch' => null, 'searchWildcardsEnabled' => null, 'output' => API_OUTPUT_EXTEND, 'selectGroups' => null, 'selectHosts' => null, 'countOutput' => null, 'preservekeys' => null, 'sortfield' => '', 'sortorder' => '', 'limit' => null);
     $options = zbx_array_merge($defOptions, $options);
     // editable + permission check
     if ($userType != USER_TYPE_SUPER_ADMIN) {
         if (!is_null($options['editable'])) {
             return $result;
         }
         $userGroups = getUserGroupsByUserId($userid);
         $sqlParts['where'][] = '(s.usrgrpid IS NULL OR ' . dbConditionInt('s.usrgrpid', $userGroups) . ')';
         $sqlParts['where'][] = '(s.groupid IS NULL OR EXISTS (' . 'SELECT NULL' . ' FROM rights r' . ' WHERE s.groupid=r.id' . ' AND ' . dbConditionInt('r.groupid', $userGroups) . ' GROUP BY r.id' . ' HAVING MIN(r.permission)>' . PERM_DENY . '))';
     }
     // groupids
     if (!is_null($options['groupids'])) {
         zbx_value2array($options['groupids']);
         $sqlParts['where'][] = '(s.groupid IS NULL OR ' . dbConditionInt('s.groupid', $options['groupids']) . ')';
     }
     // hostids
     if (!is_null($options['hostids'])) {
         zbx_value2array($options['hostids']);
         // return scripts that are assigned to the hosts' groups or to no group
         $hostGroups = API::HostGroup()->get(array('output' => array('groupid'), 'hostids' => $options['hostids']));
         $hostGroupIds = zbx_objectValues($hostGroups, 'groupid');
         $sqlParts['where'][] = '(' . dbConditionInt('s.groupid', $hostGroupIds) . ' OR s.groupid IS NULL)';
     }
     // usrgrpids
     if (!is_null($options['usrgrpids'])) {
         zbx_value2array($options['usrgrpids']);
         $sqlParts['where'][] = '(s.usrgrpid IS NULL OR ' . dbConditionInt('s.usrgrpid', $options['usrgrpids']) . ')';
     }
     // scriptids
     if (!is_null($options['scriptids'])) {
         zbx_value2array($options['scriptids']);
         $sqlParts['where'][] = dbConditionInt('s.scriptid', $options['scriptids']);
     }
     // search
     if (is_array($options['search'])) {
         zbx_db_search('scripts s', $options, $sqlParts);
     }
     // filter
     if (is_array($options['filter'])) {
         $this->dbFilter('scripts s', $options, $sqlParts);
     }
     // limit
     if (zbx_ctype_digit($options['limit']) && $options['limit']) {
         $sqlParts['limit'] = $options['limit'];
     }
     $sqlParts = $this->applyQueryOutputOptions($this->tableName(), $this->tableAlias(), $options, $sqlParts);
     $sqlParts = $this->applyQuerySortOptions($this->tableName(), $this->tableAlias(), $options, $sqlParts);
     $res = DBselect($this->createSelectQueryFromParts($sqlParts), $sqlParts['limit']);
     while ($script = DBfetch($res)) {
         if ($options['countOutput']) {
             $result = $script['rowscount'];
         } else {
             $result[$script['scriptid']] = $script;
         }
     }
     if (!is_null($options['countOutput'])) {
         return $result;
     }
     if ($result) {
         $result = $this->addRelatedObjects($options, $result);
         $result = $this->unsetExtraFields($result, array('groupid', 'host_access'), $options['output']);
     }
     // removing keys (hash -> array)
     if (is_null($options['preservekeys'])) {
         $result = zbx_cleanHashes($result);
     }
     return $result;
 }
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:93,代码来源:CScript.php


示例8: get


//.........这里部分代码省略.........
     // itemids
     if (!is_null($options['itemids'])) {
         zbx_value2array($options['itemids']);
         $sqlParts['from']['graphs_items'] = 'graphs_items gi';
         $sqlParts['where']['gig'] = 'gi.graphid=g.graphid';
         $sqlParts['where'][] = dbConditionInt('gi.itemid', $options['itemids']);
         if (!is_null($options['groupCount'])) {
             $sqlParts['group']['gi'] = 'gi.itemid';
         }
     }
     // discoveryids
     if (!is_null($options['discoveryids'])) {
         zbx_value2array($options['discoveryids']);
         $sqlParts['from']['graphs_items'] = 'graphs_items gi';
         $sqlParts['from']['item_discovery'] = 'item_discovery id';
         $sqlParts['where']['gig'] = 'gi.graphid=g.graphid';
         $sqlParts['where']['giid'] = 'gi.itemid=id.itemid';
         $sqlParts['where'][] = dbConditionInt('id.parent_itemid', $options['discoveryids']);
         if (!is_null($options['groupCount'])) {
             $sqlParts['group']['id'] = 'id.parent_itemid';
         }
     }
     // templated
     if (!is_null($options['templated'])) {
         $sqlParts['from']['graphs_items'] = 'graphs_items gi';
         $sqlParts['from']['items'] = 'items i';
         $sqlParts['from']['hosts'] = 'hosts h';
         $sqlParts['where']['igi'] = 'i.itemid=gi.itemid';
         $sqlParts['where']['ggi'] = 'g.graphid=gi.graphid';
         $sqlParts['where']['hi'] = 'h.hostid=i.hostid';
         if ($options['templated']) {
             $sqlParts['where'][] = 'h.status=' . HOST_STATUS_TEMPLATE;
         } else {
             $sqlParts['where'][] = 'h.status<>' . HOST_STATUS_TEMPLATE;
         }
     }
     // inherited
     if (!is_null($options['inherited'])) {
         if ($options['inherited']) {
             $sqlParts['where'][] = 'g.templateid IS NOT NULL';
         } else {
             $sqlParts['where'][] = 'g.templateid IS NULL';
         }
     }
     // search
     if (is_array($options['search'])) {
         zbx_db_search('graphs g', $options, $sqlParts);
     }
     // filter
     if (is_array($options['filter'])) {
         $this->dbFilter('graphs g', $options, $sqlParts);
         if (isset($options['filter']['host'])) {
             zbx_value2array($options['filter']['host']);
             $sqlParts['from']['graphs_items'] = 'graphs_items gi';
             $sqlParts['from']['items'] = 'items i';
             $sqlParts['from']['hosts'] = 'hosts h';
             $sqlParts['where']['gig'] = 'gi.graphid=g.graphid';
             $sqlParts['where']['igi'] = 'i.itemid=gi.itemid';
             $sqlParts['where']['hi'] = 'h.hostid=i.hostid';
             $sqlParts['where']['host'] = dbConditionString('h.host', $options['filter']['host']);
         }
         if (isset($options['filter']['hostid'])) {
             zbx_value2array($options['filter']['hostid']);
             $sqlParts['from']['graphs_items'] = 'graphs_items gi';
             $sqlParts['from']['items'] = 'items i';
             $sqlParts['where']['gig'] = 'gi.graphid=g.graphid';
             $sqlParts['where']['igi'] = 'i.itemid=gi.itemid';
             $sqlParts['where']['hostid'] = dbConditionInt('i.hostid', $options['filter']['hostid']);
         }
     }
     // limit
     if (zbx_ctype_digit($options['limit']) && $options['limit']) {
         $sqlParts['limit'] = $options['limit'];
     }
     $sqlParts = $this->applyQueryOutputOptions($this->tableName(), $this->tableAlias(), $options, $sqlParts);
     $sqlParts = $this->applyQuerySortOptions($this->tableName(), $this->tableAlias(), $options, $sqlParts);
     $dbRes = DBselect($this->createSelectQueryFromParts($sqlParts), $sqlParts['limit']);
     while ($graph = DBfetch($dbRes)) {
         if (!is_null($options['countOutput'])) {
             if (!is_null($options['groupCount'])) {
                 $result[] = $graph;
             } else {
                 $result = $graph['rowscount'];
             }
         } else {
             $result[$graph['graphid']] = $graph;
         }
     }
     if (!is_null($options['countOutput'])) {
         return $result;
     }
     if ($result) {
         $result = $this->addRelatedObjects($options, $result);
     }
     // removing keys (hash -> array)
     if (is_null($options['preservekeys'])) {
         $result = zbx_cleanHashes($result);
     }
     return $result;
 }
开发者ID:TonywalkerCN,项目名称:Zabbix,代码行数:101,代码来源:CGraphPrototype.php


示例9: get


//.........这里部分代码省略.........
     }
     // countOutput
     if (!is_null($options['countOutput'])) {
         $options['sortfield'] = '';
         $sql_parts['select'] = array('count(DISTINCT h.hostid) as rowscount');
         //groupCount
         if (!is_null($options['groupCount'])) {
             foreach ($sql_parts['group'] as $key => $fields) {
                 $sql_parts['select'][$key] = $fields;
             }
         }
     }
     // groupOutput
     $groupOutput = false;
     if (!is_null($options['groupOutput'])) {
         if (str_in_array('h.' . $options['groupOutput'], $sql_parts['select']) || str_in_array('h.*', $sql_parts['select'])) {
             $groupOutput = true;
         }
     }
     // order
     // restrict not allowed columns for sorting
     $options['sortfield'] = str_in_array($options['sortfield'], $sort_columns) ? $options['sortfield'] : '';
     if (!zbx_empty($options['sortfield'])) {
         $sortorder = $options['sortorder'] == ZBX_SORT_DOWN ? ZBX_SORT_DOWN : ZBX_SORT_UP;
         if ($options['sortfield'] == 'clock') {
             $sql_parts['order']['itemid'] = 'h.itemid ' . $sortorder;
         }
         $sql_parts['order'][$options['sortfield']] = 'h.' . $options['sortfield'] . ' ' . $sortorder;
         if (!str_in_array('h.' . $options['sortfield'], $sql_parts['select']) && !str_in_array('h.*', $sql_parts['select'])) {
             $sql_parts['select'][$options['sortfield']] = 'h.' . $options['sortfield'];
         }
     }
     // limit
     if (zbx_ctype_digit($options['limit']) && $options['limit']) {
         $sql_parts['limit'] = $options['limit'];
     }
     //---------------
     $itemids = array();
     $triggerids = array();
     $sql_parts['select'] = array_unique($sql_parts['select']);
     $sql_parts['from'] = array_unique($sql_parts['from']);
     $sql_parts['where'] = array_unique($sql_parts['where']);
     $sql_parts['order'] = array_unique($sql_parts['order']);
     $sql_select = '';
     $sql_from = '';
     $sql_where = '';
     $sql_order = '';
     if (!empty($sql_parts['select'])) {
         $sql_select .= implode(',', $sql_parts['select']);
     }
     if (!empty($sql_parts['from'])) {
         $sql_from .= implode(',', $sql_parts['from']);
     }
     if (!empty($sql_parts['where'])) {
         $sql_where .= implode(' AND ', $sql_parts['where']);
     }
     if (!empty($sql_parts['order'])) {
         $sql_order .= ' ORDER BY ' . implode(',', $sql_parts['order']);
     }
     $sql_limit = $sql_parts['limit'];
     $sql = 'SELECT ' . $sql_select . ' FROM ' . $sql_from . ' WHERE ' . $sql_where . $sql_order;
     $db_res = DBselect($sql, $sql_limit);
     //SDI($sql);
     $count = 0;
     $group = array();
     while ($data = DBfetch($db_res)) {
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:67,代码来源:class.chistory.php


示例10: get


//.........这里部分代码省略.........
     }
     // search
     if (is_array($options['search'])) {
         zbx_db_search('items i', $options, $sqlParts);
     }
     // --- FILTER ---
     if (is_array($options['filter'])) {
         $this->dbFilter('items i', $options, $sqlParts);
         if (isset($options['filter']['host'])) {
             zbx_value2array($options['filter']['host']);
             $sqlParts['from']['hosts'] = 'hosts h';
             $sqlParts['where']['hi'] = 'h.hostid=i.hostid';
             $sqlParts['where']['h'] = dbConditionString('h.host', $options['filter']['host']);
         }
     }
     // output
     if ($options['output'] == API_OUTPUT_EXTEND) {
         $sqlParts['select']['items'] = 'i.*';
     }
     // countOutput
     if (!is_null($options['countOutput'])) {
         $options['sortfield'] = '';
         $sqlParts['select'] = array('count(DISTINCT i.itemid) as rowscount');
         //groupCount
         if (!is_null($options['groupCount'])) {
             foreach ($sqlParts['group'] as $key => $fields) {
                 $sqlParts['select'][$key] = $fields;
             }
         }
     }
     // sorting
     zbx_db_sorting($sqlParts, $options, $sortColumns, 'i');
     // limit
     if (zbx_ctype_digit($options['limit']) && $options['limit']) {
         $sqlParts['limit'] = $options['limit'];
     }
     //----------
     $itemids = array();
     $sqlParts['select'] = array_unique($sqlParts['select']);
     $sqlParts['from'] = array_unique($sqlParts['from']);
     $sqlParts['where'] = array_unique($sqlParts['where']);
     $sqlParts['group'] = array_unique($sqlParts['group']);
     $sqlParts['order'] = array_unique($sqlParts['order']);
     $sqlSelect = '';
     $sqlFrom = '';
     $sqlWhere = '';
     $sqlGroup = '';
     $sqlOrder = '';
     if (!empty($sqlParts['select'])) {
         $sqlSelect .= implode(',', $sqlParts['select']);
     }
     if (!empty($sqlParts['from'])) {
         $sqlFrom .= implode(',', $sqlParts['from']);
     }
     if (!empty($sqlParts['where'])) {
         $sqlWhere .= ' AND ' . implode(' AND ', $sqlParts['where']);
     }
     if (!empty($sqlParts['group'])) {
         $sqlWhere .= ' GROUP BY ' . implode(',', $sqlParts['group']);
     }
     if (!empty($sqlParts['order'])) {
         $sqlOrder .= ' ORDER BY ' . implode(',', $sqlParts['order']);
     }
     $sqlLimit = $sqlParts['limit'];
     $sql = 'SELECT ' . zbx_db_distinct($sqlParts) . ' ' . $sqlSelect . ' FROM ' . $sqlFrom . ' WHERE ' . DBin_node('i.itemid', $nodeids) . $sqlWhere . $sqlGroup . $sqlOrder;
     //SDI($sql);
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:67,代码来源:CItemPrototype.php


示例11: get


//.........这里部分代码省略.........
                 $sqlParts['select'][$key] = $fields;
             }
         }
     }
     // search
     if (is_array($options['search'])) {
         zbx_db_search('graphs g', $options, $sqlParts);
     }
     // filter
     if (is_array($options['filter'])) {
         $this->dbFilter('graphs g', $options, $sqlParts);
         if (isset($options['filter']['host'])) {
             zbx_value2array($options['filter']['host']);
             $sqlParts['from']['graphs_items'] = 'graphs_items gi';
             $sqlParts['from']['items'] = 'items i';
             $sqlParts['from']['hosts'] = 'hosts h';
             $sqlParts['where']['gig'] = 'gi.graphid=g.graphid';
             $sqlParts['where']['igi'] = 'i.itemid=gi.itemid';
             $sqlParts['where']['hi'] = 'h.hostid=i.hostid';
             $sqlParts['where']['host'] = dbConditionString('h.host', $options['filter']['host']);
         }
         if (isset($options['filter']['hostid'])) {
             zbx_value2array($options['filter']['hostid']);
             $sqlParts['from']['graphs_items'] = 'graphs_items gi';
             $sqlParts['from']['items'] = 'items i';
             $sqlParts['where']['gig'] = 'gi.graphid=g.graphid';
             $sqlParts['where']['igi'] = 'i.itemid=gi.itemid';
             $sqlParts['where']['hostid'] = dbConditionInt('i.hostid', $options['filter']['hostid']);
         }
     }
     // sorting
     zbx_db_sorting($sqlParts, $options, $sortColumns, 'g');
     // limit
     if (zbx_ctype_digit($options['limit']) && $options['limit']) {
         $sqlParts['limit'] = $options['limit'];
     }
     $graphids = array();
     $sqlParts['select'] = array_unique($sqlParts['select']);
     $sqlParts['from'] = array_unique($sqlParts['from']);
     $sqlParts['where'] = array_unique($sqlParts['where']);
     $sqlParts['group'] = array_unique($sqlParts['group']);
     $sqlParts['order'] = array_unique($sqlParts['order']);
     $sqlSelect = '';
     $sqlFrom = '';
     $sqlWhere = '';
     $sqlGroup = '';
     $sqlOrder = '';
     if (!empty($sqlParts['select'])) {
         $sqlSelect .= implode(',', $sqlParts['select']);
     }
     if (!empty($sqlParts['from'])) {
         $sqlFrom .= implode(',', $sqlParts['from']);
     }
     if (!empty($sqlParts['where'])) {
         $sqlWhere .= ' AND ' . implode(' AND ', $sqlParts['where']);
     }
     if (!empty($sqlParts['group'])) {
         $sqlWhere .= ' GROUP BY ' . implode(',', $sqlParts['group']);
     }
     if (!empty($sqlParts['order'])) {
         $sqlOrder .= ' ORDER BY ' . implode(',', $sqlParts['order']);
     }
     $sqlLimit = $sqlParts['limit'];
     $sql = 'SELECT ' . zbx_db_distinct($sqlParts) . ' ' . $sqlSelect . ' FROM ' . $sqlFrom . ' WHERE ' . DBin_node('g.graphid', $nodeids) . $sqlWhere . $sqlGroup . $sqlOrder;
     $dbRes = DBselect($sql, $sqlLimit);
     while ($graph = DBfetch($dbRes)) {
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:67,代码来源:CGraphPrototype.php


示例12: DBaddLimit

/**
 * Add the LIMIT clause to the given query.
 *
 * NOTE:
 * LIMIT and OFFSET records
 *
 * Example: select 6-15 row.
 *
 * MySQL:
 * SELECT a FROM tbl LIMIT 5,10
 * SELECT a FROM tbl LIMIT 10 OFFSET 5
 *
 * PostgreSQL:
 * SELECT a FROM tbl LIMIT 10 OFFSET 5
 *
 * Oracle, DB2:
 * SELECT a FROM tbe WHERE rownum < 15 // ONLY < 15
 * SELECT * FROM (SELECT * FROM tbl) WHERE rownum BETWEEN 6 AND 15
 *
 * @param $query
 * @param int $limit    max number of record to return
 * @param int $offset   return starting from $offset record
 *
 * @return bool|string
 */
function DBaddLimit($query, $limit = 0, $offset = 0)
{
    global $DB;
    if (isset($limit) && ($limit < 0 || !zbx_ctype_digit($limit)) || $offset < 0 || !zbx_ctype_digit($offset)) {
        $moreDetails = isset($limit) ? ' Limit [' . $limit . '] Offset [' . $offset . ']' : ' Offset [' . $offset . ']';
        error('Incorrect parameters for limit and/or offset. Query [' . $query . ']' . $moreDetails);
        return false;
    }
    // Process limit and offset
    if (isset($limit)) {
        switch ($DB['TYPE']) {
            case ZBX_DB_MYSQL:
            case ZBX_DB_POSTGRESQL:
            case ZBX_DB_SQLITE3:
                $query .= ' LIMIT ' . intval($limit) . ' OFFSET ' . intval($offset);
                break;
            case ZBX_DB_ORACLE:
            case ZBX_DB_DB2:
                $till = $offset + $limit;
                $query = 'SELECT * FROM (' . $query . ') WHERE rownum BETWEEN ' . intval($offset) . ' AND ' . intval($till);
                break;
        }
    }
    return $query;
}
开发者ID:TonywalkerCN,项目名称:Zabbix,代码行数:50,代码来源:db.inc.php


示例13: zbx_cleanHashes

function zbx_cleanHashes(&$value)
{
    if (is_array($value)) {
        // reset() is needed to move internal array pointer to the beginning of the array
        reset($value);
        if (zbx_ctype_digit(key($value))) {
            $value = array_values($value);
        }
    }
    return $value;
}
开发者ID:TonywalkerCN,项目名称:Zabbix,代码行数:11,代码来源:func.inc.php


示例14: checkValueTypes

 public static function checkValueTypes($table, &$values)
 {
     global $DB;
     $tableSchema = self::getSchema($table);
     foreach ($values as $field => $value) {
         if (!isset($tableSchema['fields'][$field])) {
             unset($values[$field]);
             continue;
         }
         if (isset($tableSchema['fields'][$field]['ref_table'])) {
             if ($tableSchema['fields'][$field]['null']) {
                 $values[$field] = $values[$field] == '0' ? NULL : $values[$field];
             }
         }
         if (is_null($values[$field])) {
             if ($tableSchema['fields'][$field]['null']) {
                 $values[$field] = 'NULL';
             } elseif (isset($tableSchema['fields'][$field]['default'])) {
                 $values[$field] = zbx_dbstr($tableSchema['fields'][$field]['default']);
             } else {
                 self::exception(self::DBEXECUTE_ERROR, _s('Field "%1$s" cannot be set to NULL.', $field));
             }
         } else {
             switch ($tableSchema['fields'][$field]['type']) {
                 case self::FIELD_TYPE_CHAR:
                     $length = mb_strlen($values[$field]);
                     $values[$field] = zbx_dbstr($values[$field]);
                     if ($length > $tableSchema['fields'][$field]['length']) {
                         self::exception(self::SCHEMA_ERROR, _s('Value "%1$s" is too long for field "%2$s" - %3$d characters. Allowed length is %4$d characters.', $values[$field], $field, $length, $tableSchema['fields'][$field]['length']));
                     }
                     break;
                 case self::FIELD_TYPE_ID:
                 case self::FIELD_TYPE_UINT:
                     if (!zbx_ctype_digit($values[$field])) {
                         self::exception(self::DBEXECUTE_ERROR, _s('Incorrect value "%1$s" for unsigned int field "%2$s".', $values[$field], $field));
                     }
                     $values[$field] = zbx_dbstr($values[$field]);
                     break;
                 case self::FIELD_TYPE_INT:
                     if (!zbx_is_int($values[$field])) {
                         self::exception(self::DBEXECUTE_ERROR, _s('Incorrect value "%1$s" for int field "%2$s".', $values[$field], $field));
                     }
                     $values[$field] = zbx_dbstr($values[$field]);
                     break;
                 case self::FIELD_TYPE_FLOAT:
                     if (!is_numeric($values[$field])) {
                         self::exception(self::DBEXECUTE_ERROR, _s('Incorrect value "%1$s" for float field "%2$s".', $values[$field], $field));
                     }
                     $values[$field] = zbx_dbstr($values[$field]);
                     break;
                 case self::FIELD_TYPE_TEXT:
                     $length = mb_strlen($values[$field]);
                     $values[$field] = zbx_dbstr($values[$field]);
                     if ($DB['TYPE'] == ZBX_DB_DB2 || $DB['TYPE'] == ZBX_DB_ORACLE) {
                         if ($length > 2048) {
                             self::exception(self::SCHEMA_ERROR, _s('Value "%1$s" is too long for field "%2$s" - %3$d characters. Allowed length is 2048 characters.', $values[$field], $field, $length));
                         }
                     }
                     break;
             }
         }
     }
 }
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:63,代码来源:DB.php


示例15: get


//.........这里部分代码省略.........
     if (is_array($options['filter'])) {
         $this->dbFilter($sqlParts['from']['history'], $options, $sqlParts);
     }
     // search
     if (is_array($options['search'])) {
         zbx_db_search($sqlParts['from']['history'], $options, $sqlParts);
     }
     // output
     if ($options['output'] == API_OUTPUT_EXTEND) {
         unset($sqlParts['select']['clock']);
         $sqlParts['select']['history'] = 'h.*';
     }
     // countOutput
     if (!is_null($options['countOutput'])) {
         $options['sortfield'] = '';
         $sqlParts['select'] = array('count(DISTINCT h.hostid) as rowscount');
         // groupCount
         if (!is_null($options['groupCount'])) {
             foreach ($sqlParts['group'] as $key => $fields) {
                 $sqlParts['select'][$key] = $fields;
             }
         }
     }
     // groupOutput
     $groupOutput = false;
     if (!is_null($options['groupOutput'])) {
         if (str_in_array('h.' . $options['groupOutput'], $sqlParts['select']) || str_in_array('h.*', $sqlParts['select'])) {
             $groupOutput = true;
         }
     }
     // sorting
     zbx_db_sorting($sqlParts, $options, $sortColumns, 'h');
     // limit
     if (zbx_ctype_digit($options['limit']) && $options['limit']) {
         $sqlParts['limit'] = $options['limit'];
     }
     $itemids = array();
     $sqlParts['select'] = array_unique($sqlParts['select']);
     $sqlParts['from'] = array_unique( 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP zbx_date2age函数代码示例发布时间:2022-05-23
下一篇:
PHP zbx_cleanHashes函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap