From 70c3ce9b9fcbd9a88443989f08694c16870ddf4e Mon Sep 17 00:00:00 2001 From: rohieb Date: Sat, 26 Jul 2008 02:13:35 +0200 Subject: [PATCH] mod_roomReservationRoomsManager: added getRoomByName() and getRoomByOid() --- includes/mod_roomReservationRoomsManager.inc | 34 ++++++++++++++++++++ 1 file changed, 34 insertions(+) mode change 100755 => 100644 includes/mod_roomReservationRoomsManager.inc diff --git a/includes/mod_roomReservationRoomsManager.inc b/includes/mod_roomReservationRoomsManager.inc old mode 100755 new mode 100644 index 732b3dc..edce221 --- a/includes/mod_roomReservationRoomsManager.inc +++ b/includes/mod_roomReservationRoomsManager.inc @@ -113,6 +113,40 @@ class mod_roomReservationRoomsManager { } */ + /** + * Get a room by its OID. Returns null if the room was not found. + * @param $nOid (integer) The OID of the room + * @return mod_roomReservationRoom + */ + static function getRoomByOid($nOid) { + $o = null; + $h = db_query("SELECT * FROM rooms WHERE oid = $1;", $nOid); + if(pg_num_rows($h) > 0) { + $arResult = pg_fetch_array($h); + $o = new mod_roomReservationRoom($arResult["name"], + $arResult["room_no"], $arResult["floor"], $arResult["building"], + $arResult["location"]); + } + return $o; + } + + /** + * Get a room by its name. Returns null if the room was not found. + * @param $sName (string) The name of the room + * @return mod_roomReservationRoom + */ + static function getRoomByName($sName) { + $o = null; + $h = db_query("SELECT * FROM rooms WHERE name = $1;", $sName); + if(pg_num_rows($h) > 0) { + $arResult = pg_fetch_array($h); + $o = new mod_roomReservationRoom($arResult["name"], + $arResult["room_no"], $arResult["floor"], $arResult["building"], + $arResult["location"]); + } + return $o; + } + /** * Get all rooms from the database * @return array of mod_roomReservationRoom -- 2.20.1