ocs  2.3.6
About: OCS (Open Conference System) is a Web publishing tool that will create a complete Web presence for your scholarly conference.
  Fossies Dox: ocs-2.3.6.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

RoomDAO.inc.php
Go to the documentation of this file.
1 <?php
2 
16 //$Id$
17 
18 import('scheduler.Room');
19 
20 class RoomDAO extends DAO {
26  function &getRoom($roomId) {
27  $result =& $this->retrieve(
28  'SELECT * FROM rooms WHERE room_id = ?', $roomId
29  );
30 
31  $returner = null;
32  if ($result->RecordCount() != 0) {
33  $returner =& $this->_returnRoomFromRow($result->GetRowAssoc(false));
34  }
35  $result->Close();
36  return $returner;
37  }
38 
44  function getRoomBuildingId($roomId) {
45  $result =& $this->retrieve(
46  'SELECT building_id FROM rooms WHERE room_id = ?', $roomId
47  );
48 
49  return isset($result->fields[0]) ? $result->fields[0] : 0;
50  }
51 
57  function getRoomSchedConfId($roomId) {
58  $result =& $this->retrieve(
59  'SELECT b.sched_conf_id FROM rooms r LEFT JOIN buildings b ON (r.building_id = b.building_id) WHERE r.room_id = ?', $roomId
60  );
61 
62  return isset($result->fields[0]) ? $result->fields[0] : 0;
63  }
64 
69  function getLocaleFieldNames() {
70  return array('name', 'abbrev', 'description');
71  }
72 
78  function &_returnRoomFromRow(&$row) {
79  $room = new Room();
80  $room->setId($row['room_id']);
81  $room->setBuildingId($row['building_id']);
82  $this->getDataObjectSettings('room_settings', 'room_id', $row['room_id'], $room);
83 
84  return $room;
85  }
86 
91  function updateLocaleFields(&$room) {
92  $this->updateDataObjectSettings('room_settings', $room, array(
93  'room_id' => $room->getId()
94  ));
95  }
96 
102  function insertRoom(&$room) {
103  $this->update(
104  sprintf('INSERT INTO rooms
105  (building_id)
106  VALUES
107  (?)'),
108  array(
109  $room->getBuildingId()
110  )
111  );
112  $room->setId($this->getInsertRoomId());
113  $this->updateLocaleFields($room);
114  return $room->getId();
115  }
116 
122  function updateRoom(&$room) {
123  $returner = $this->update(
124  sprintf('UPDATE rooms
125  SET
126  building_id = ?
127  WHERE room_id = ?'),
128  array(
129  $room->getBuildingId(),
130  $room->getId()
131  )
132  );
133  $this->updateLocaleFields($room);
134  return $returner;
135  }
136 
142  function deleteRoom($room) {
143  return $this->deleteRoomById($room->getId());
144  }
145 
151  function deleteRoomById($roomId) {
152  $this->update('DELETE FROM room_settings WHERE room_id = ?', $roomId);
153  $ret = $this->update('DELETE FROM rooms WHERE room_id = ?', $roomId);
154  return $ret;
155  }
156 
161  function deleteRoomsByBuildingId($buildingId) {
162  $rooms =& $this->getRoomsByBuildingId($buildingId);
163  while (($room =& $rooms->next())) {
164  $this->deleteRoom($room);
165  unset($room);
166  }
167  }
168 
174  function &getRoomsByBuildingId($buildingId, $rangeInfo = null) {
175  $result =& $this->retrieveRange(
176  'SELECT * FROM rooms WHERE building_id = ? ORDER BY building_id',
177  $buildingId,
178  $rangeInfo
179  );
180 
181  $returner = new DAOResultFactory($result, $this, '_returnRoomFromRow');
182  return $returner;
183  }
184 
189  function getInsertRoomId() {
190  return $this->getInsertId('rooms', 'room_id');
191  }
192 }
193 
194 ?>
deleteRoom($room)
config TEMPLATE inc php
Definition: config.inc.php:4
Operations for retrieving and modifying objects from a database.
Definition: DAO.inc.php:30
deleteRoomById($roomId)
& retrieve($sql, $params=false, $callHooks=true)
Definition: DAO.inc.php:62
getInsertId($table='', $id='', $callHooks=true)
Definition: DAO.inc.php:225
getRoomBuildingId($roomId)
Definition: RoomDAO.inc.php:44
& getRoom($roomId)
Definition: RoomDAO.inc.php:26
updateDataObjectSettings($tableName, &$dataObject, $idArray)
Definition: DAO.inc.php:412
& retrieveRange($sql, $params=false, $dbResultRange=null, $callHooks=true)
Definition: DAO.inc.php:152
& _returnRoomFromRow(&$row)
Definition: RoomDAO.inc.php:78
& getRoomsByBuildingId($buildingId, $rangeInfo=null)
Wrapper around ADORecordSet providing "factory" features for generating objects from DAOs.
updateLocaleFields(&$room)
Definition: RoomDAO.inc.php:91
getInsertRoomId()
insertRoom(&$room)
getLocaleFieldNames()
Definition: RoomDAO.inc.php:69
deleteRoomsByBuildingId($buildingId)
Operations for retrieving and modifying Room objects.
Definition: RoomDAO.inc.php:20
getDataObjectSettings($tableName, $idFieldName, $idFieldValue, &$dataObject)
Definition: DAO.inc.php:498
update($sql, $params=false, $callHooks=true, $dieOnError=true)
Definition: DAO.inc.php:186
updateRoom(&$room)
getRoomSchedConfId($roomId)
Definition: RoomDAO.inc.php:57
Basic class describing a room.
Definition: Room.inc.php:18