From e85ba683e1811fca1f291d89e5f9ac748fdd9edd Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 1 Dec 2015 14:29:57 -0500 Subject: [PATCH] improve constructor to handle numeric as well, and give error when something else --- web/includes/Monitor.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/web/includes/Monitor.php b/web/includes/Monitor.php index 2cb948952..6d28b5c41 100644 --- a/web/includes/Monitor.php +++ b/web/includes/Monitor.php @@ -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 ) {