improve constructor to handle numeric as well, and give error when something else
parent
e4f5f76782
commit
e85ba683e1
|
@ -5,10 +5,15 @@ require_once( 'Server.php' );
|
|||
class Monitor {
|
||||
public function __construct( $IdOrRow ) {
|
||||
$row = NULL;
|
||||
if ( is_int( $dOrRow ) ) {
|
||||
if ( is_int( $IdOrRow ) ) {
|
||||
$row = dbFetchOne( 'SELECT * FROM Monitors WHERE Id=?', NULL, array( $IdOrRow ) );
|
||||
} else if ( is_array($idOrRow) ) {
|
||||
$row = $idOrRow;
|
||||
} else if ( is_numeric( $IdOrRow ) ) {
|
||||
$row = dbFetchOne( 'SELECT * FROM Monitors WHERE Id=?', NULL, array( $IdOrRow ) );
|
||||
} else if ( is_array($IdOrRow) ) {
|
||||
$row = $IdOrRow;
|
||||
} else {
|
||||
Error("Unknown argument passed to Monitor Constructor ($IdOrRow)");
|
||||
return;
|
||||
}
|
||||
|
||||
if ( $row ) {
|
||||
|
|
Loading…
Reference in New Issue