PHP and DB2 working together -
i'm trying script:
//agent d4 offline events last 24h $q_d4_offline_last24h = "select distinct node, lastoccurrence, inps_close_timestamp reporter.reporter_status alertkey = 'm_sw_mid_mon_ser_sts_006c_all' , nodealias '%:d4' , lastoccurrence > date(current_date -1 days)"; $db2_reporter_conn = new ldbproxy(); if(!$db2_reporter_conn->connect_db2("192.168.8.245:50001", "reporter", "itmuser", "tivoli")) die ('e:connessione al db2 fallita:' . $db2_reporter_conn->errormsg); $connettore = $db2_reporter_conn->query($q_d4_offline_last24h) or die("e:errore nella query: " . $db2_reporter_conn->errormsg); $rownum = count($db2_reporter_conn->fetch($connettore)); if($rownum > 0) { $prev_node=null; echo "\n - eventi di offline relativi ad agent itcam soa rilevati nelle ultime 24 ore:\n\n"; while($row = $db2_reporter_conn->fetch($connettore)){ if ( $row['node'] != $prev_node ) { echo "\n\t" . $row['node']; $prev_hostname = $row['node']; } echo "\n\t\tdata inizio: " . substr($row['lastoccurrence'],0,-2); if($row['inps_close_timestamp'] == '1970-01-01 01:00:00.0') echo "\n\t\tdata fine: n/a"; else echo "\n\t\tdata fine: " . substr($row['inps_close_timestamp'],0,-2) . "\n"; } }
usually query use out 3 rows result. don't understand why in output last 2 rows, jumps first row.
can me?
this statement fetching first result row, , not using anything. gets discarded:
$rownum = count($db2_reporter_conn->fetch($connettore));
if dealing small number of rows, more convenient use fetchall
. rows @ once, can check how many there are, , use loop process them.
.
Comments
Post a Comment