Slight update to allow the instantiation with no row or Id

pull/1207/head
Isaac Connor 2015-12-22 09:52:33 -05:00
parent 1aa79c306b
commit 6df1425897
1 changed files with 13 additions and 10 deletions

View File

@ -5,16 +5,19 @@ require_once( 'Server.php' );
class Monitor { class Monitor {
public function __construct( $IdOrRow ) { public function __construct( $IdOrRow ) {
$row = NULL; $row = NULL;
if ( is_int( $IdOrRow ) ) { if ( $IdOrRow ) {
$row = dbFetchOne( 'SELECT * FROM Monitors WHERE Id=?', NULL, array( $IdOrRow ) ); if ( is_integer( $IdOrRow ) or is_numeric( $IdOrRow ) ) {
} else if ( is_numeric( $IdOrRow ) ) { $row = dbFetchOne( 'SELECT * FROM Monitors WHERE Id=?', NULL, array( $IdOrRow ) );
$row = dbFetchOne( 'SELECT * FROM Monitors WHERE Id=?', NULL, array( $IdOrRow ) ); if ( ! $row ) {
} else if ( is_array($IdOrRow) ) { Error("Unable to load Server record for Id=" . $IdOrRow );
$row = $IdOrRow; }
} else { } elseif ( is_array( $IdOrRow ) ) {
Error("Unknown argument passed to Monitor Constructor ($IdOrRow)"); $row = $IdOrRow;
return; } else {
} Error("Unknown argument passed to Monitor Constructor ($IdOrRow)");
return;
}
} # end if isset($IdOrRow)
if ( $row ) { if ( $row ) {
foreach ($row as $k => $v) { foreach ($row as $k => $v) {