improve constructor to handle numeric as well, and give error when something else

pull/1207/head
Isaac Connor 2015-12-01 14:29:57 -05:00
parent e4f5f76782
commit e85ba683e1
1 changed files with 8 additions and 3 deletions

View File

@ -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 ) {