Example #1
0
 public static function getMergedParametersBySearch($firstTableParams = array(), $secondTableParams = array(), $count = -1, $offset = 0, $order = null, $sort = "ASC", $filters = array(), $filterType = "OR", $relationTableParams = array(), $aAddFilters = array(), $aGroup = array())
 {
     if (is_null(static::$resourceType)) {
         throw new \Exception("Bad resource type.");
     }
     $filters = array_merge($filters, array('resource_type' => static::$resourceType));
     return parent::getMergedParametersBySearch($firstTableParams, $secondTableParams, $count, $offset, $order, $sort, $filters, 'AND', $relationTableParams, $aAddFilters, $aGroup);
 }
Example #2
0
 public static function getMergedParameters($firstTableParams = array(), $secondTableParams = array(), $count = -1, $offset = 0, $order = null, $sort = "ASC", $filters = array(), $filterType = "OR", $relationTableParams = array())
 {
     $fString = "";
     $sString = "";
     $rString = "";
     $firstObj = static::$firstObject;
     foreach ($firstTableParams as $fparams) {
         if ($fString != "") {
             $fString .= ",";
         }
         $fString .= $firstObj::getTableName() . "." . $fparams;
     }
     $secondObj = static::$secondObject;
     foreach ($secondTableParams as $sparams) {
         if ($fString != "" || $sString != "") {
             $sString .= ",";
         }
         $sString .= $secondObj::getTableName() . "." . $sparams;
     }
     foreach ($relationTableParams as $rparams) {
         if ($fString != "" || $sString != "" || $rString != "") {
             $rString .= ",";
         }
         $rString .= static::$relationTable . "." . $rparams;
     }
     $sql = "SELECT {$fString} {$sString} {$rString}\n            FROM " . $firstObj::getTableName() . "," . $secondObj::getTableName() . "," . static::$relationTable . "\n            WHERE " . $firstObj::getTableName() . "." . $firstObj::getPrimaryKey() . " = " . static::$relationTable . "." . static::$firstKey . "\n            AND " . static::$relationTable . "." . static::$secondKey . " = " . $secondObj::getTableName() . "." . $secondObj::getPrimaryKey() . "\n            AND host_register = '1'\n            AND service_register = '1' ";
     $filterTab = array();
     if (count($filters)) {
         $sql .= " AND ( ";
         $first = true;
         foreach ($filters as $key => $rawvalue) {
             if ($first) {
                 $first = false;
             } else {
                 $sql .= $filterType;
             }
             if (is_array($rawvalue)) {
                 $sql .= "(";
                 $sql .= join(" OR ", array_pad(array(), count($rawvalue), $key . " LIKE ? "));
                 $sql .= ")";
                 $filterTab = array_merge($filterTab, array_map(array('static', 'parseValueForSearch'), $rawvalue));
             } else {
                 $sql .= ' ' . $key . " LIKE ? ";
                 $filterTab[] = CentreonRelationModel::parseValueForSearch($rawvalue);
             }
         }
         $sql .= " ) ";
     }
     if (isset($order) && isset($sort) && (strtoupper($sort) == "ASC" || strtoupper($sort) == "DESC")) {
         $sql .= " ORDER BY {$order} {$sort} ";
     }
     if (isset($count) && $count != -1) {
         $db = Di::getDefault()->get('db_centreon');
         $sql = $db->limit($sql, $count, $offset);
     }
     $result = static::getResult($sql, $filterTab);
     return $result;
 }
Example #3
0
 /**
  * 
  * @param type $firstTableParams
  * @param type $secondTableParams
  * @param type $count
  * @param type $offset
  * @param type $order
  * @param type $sort
  * @param type $filters
  * @param type $filterType
  * @param type $relationTableParams
  * @return type
  */
 public static function getMergedParametersBySearch($firstTableParams = array(), $secondTableParams = array(), $count = -1, $offset = 0, $order = null, $sort = "ASC", $filters = array(), $filterType = "OR", $relationTableParams = array())
 {
     $filters['service_register'] = '1';
     $aAddFilters = array();
     $tablesString = '';
     if (array('tagname', array_values($filters)) && !empty($filters['tagname'])) {
         $aAddFilters = array('tables' => array('cfg_tags', 'cfg_tags_services'), 'join' => array('cfg_tags.tag_id = cfg_tags_services.tag_id', 'cfg_tags.tag_id = cfg_tags_services.tag_id', 'cfg_tags_services.resource_id = cfg_services.service_id '));
     }
     return parent::getMergedParametersBySearch($firstTableParams, $secondTableParams, $count, $offset, $order, $sort, $filters, $filterType, $relationTableParams, $aAddFilters);
 }
Example #4
0
 /**
  * 
  * @param type $firstTableParams
  * @param type $secondTableParams
  * @param type $count
  * @param type $offset
  * @param type $order
  * @param type $sort
  * @param type $filters
  * @param type $filterType
  * @param type $relationTableParams
  * @return type
  */
 public static function getMergedParametersBySearch($firstTableParams = array(), $secondTableParams = array(), $count = -1, $offset = 0, $order = null, $sort = "ASC", $filters = array(), $filterType = "OR", $relationTableParams = array())
 {
     $filters['service_register'] = '1';
     return parent::getMergedParametersBySearch($firstTableParams, $secondTableParams, $count, $offset, $order, $sort, $filters, $filterType, $relationTableParams);
 }