Changeset 6717

Show
Ignore:
Timestamp:
10/03/08 20:00:36 (2 months ago)
Author:
jmathis
Message:

add new function

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/centreon/www/include/common/common-Func.php

    r6646 r6717  
    305305                if (!$host_id) return; 
    306306                global $pearDB; 
    307                 while(1)        { 
     307                while (1)       { 
    308308                        $DBRESULT =& $pearDB->query("SELECT ".$field.", host_template_model_htm_id FROM host WHERE host_id = '".$host_id."' LIMIT 1"); 
    309309                        if (PEAR::isError($DBRESULT)) 
    310310                                print "DB Error : ".$DBRESULT->getDebugInfo()."<br />"; 
    311311                        $row =& $DBRESULT->fetchRow(); 
    312                         //$field_result = $row[$field]; 
    313312                        if (isset($row[$field]) && $row[$field]) 
    314313                                return $row[$field]; 
     
    318317                                break; 
    319318                } 
     319        } 
     320 
     321        function getMyHostFieldOnHost($host_id = NULL, $field)  { 
     322                global $pearDB; 
     323                 
     324                if (!$host_id)  
     325                        return; 
     326                 
     327                $DBRESULT =& $pearDB->query("SELECT ".$field.", host_template_model_htm_id FROM host WHERE host_id = '".$host_id."' LIMIT 1"); 
     328                if (PEAR::isError($DBRESULT)) 
     329                        print "DB Error : ".$DBRESULT->getDebugInfo()."<br />"; 
     330                $row =& $DBRESULT->fetchRow(); 
     331                if (isset($row[$field]) && $row[$field]) 
     332                        return $row[$field]; 
     333                else 
     334                        return 0; 
    320335        } 
    321336 
     
    531546 
    532547        function getMyHostGroupHosts($hg_id = NULL)     { 
    533                 if (!$hg_id) return; 
    534                 global $pearDB; 
     548                global $pearDB; 
     549                 
     550                if (!$hg_id)  
     551                        return; 
    535552                $hosts = array(); 
    536 //              $DBRESULT =& $pearDB->query("SELECT host_host_id FROM hostgroup_relation WHERE hostgroup_hg_id = '".$hg_id."'"); 
    537553                $DBRESULT =& $pearDB->query("SELECT hgr.host_host_id FROM hostgroup_relation hgr, host h WHERE hgr.hostgroup_hg_id = '".$hg_id."' AND h.host_id = hgr.host_host_id ORDER by h.host_name"); 
    538554                if (PEAR::isError($DBRESULT)) 
     
    541557                        $hosts[$elem["host_host_id"]] = $elem["host_host_id"]; 
    542558                $DBRESULT->free(); 
     559                unset($elem); 
    543560                return $hosts; 
    544561        } 
    545562 
    546563        function getMyHostGroupCommunity($hg_id = NULL) { 
    547                 if (!$hg_id) return; 
    548                 global $pearDB; 
     564                global $pearDB; 
     565                 
     566                if (!$hg_id)  
     567                        return; 
    549568                $DBRESULT =& $pearDB->query("SELECT hg_snmp_community FROM hostgroup WHERE hg_id = '".$hg_id."' LIMIT 1"); 
    550569                if (PEAR::isError($DBRESULT)) 
     
    557576 
    558577        function getMyHostGroupVersion($hg_id = NULL)   { 
    559                 if (!$hg_id) return; 
    560                 global $pearDB; 
     578                global $pearDB; 
     579                 
     580                if (!$hg_id)  
     581                        return; 
    561582                $DBRESULT =& $pearDB->query("SELECT hg_snmp_version FROM hostgroup WHERE hg_id = '".$hg_id."' LIMIT 1"); 
    562583                if (PEAR::isError($DBRESULT))