All pastes #247815 Raw Edit

Untitled

public text v1 · immutable
#247815 ·published 2006-11-13 22:13 UTC
rendered paste body
	if ($c_res)
	{
		$result = pg_insert($dbconn, 'ap_history', $net_columns);
		$result = pg_insert($dbconn, 'ap_history', $c_res);

		$h_res = pg_query($dbconn, "SELECT * FROM ap_history WHERE bssid = '" . $net_columns['bssid'] . "' ORDER BY lastseen DESC");
		
		$historyRows = array();
		
		while($row = pg_fetch_assoc($h_res))
			$historyRows[] = $row;
			
		$noTimeRows = $historyRows;
		
		for ($n = 0; $n < count($noTimeRows); $n++)
			$noTimeRows[$n]['lastseen'] = null;
			
		$result = pg_update($dbconn, 'ap_current', $historyRows[0], array('bssid' => $historyRows[0]['bssid']));
		
		for ($n = 0; $n < count($noTimeRows); $n++)
		{
			if ($noTimeRows[$n] === $noTimeRows[$n +1])
			{
				pg_delete($dbconn, 'ap_history', $historyRows[$n]);
			}
		}
	}