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)  

ControlledVocabEntryDAO.inc.php
Go to the documentation of this file.
1 <?php
2 
16 //$Id$
17 
18 import('controlledVocab.ControlledVocabEntry');
19 
27  function getById($controlledVocabEntryId, $controlledVocabId = null) {
28  $params = array((int) $controlledVocabEntryId);
29  if (!empty($controlledVocabId)) $params[] = (int) $controlledVocabId;
30 
31  $result =& $this->retrieve(
32  'SELECT * FROM controlled_vocab_entries WHERE controlled_vocab_entry_id = ?' .
33  (!empty($controlledVocabId)?' AND controlled_vocab_id = ?':''),
34  $params
35  );
36 
37  $returner = null;
38  if ($result->RecordCount() != 0) {
39  $returner = $this->_fromRow($result->GetRowAssoc(false));
40  }
41  $result->Close();
42  return $returner;
43  }
44 
49  function newDataObject() {
50  return new ControlledVocabEntry();
51  }
52 
59  function _fromRow(&$row) {
60  $controlledVocabEntry = $this->newDataObject();
61  $controlledVocabEntry->setControlledVocabId($row['controlled_vocab_id']);
62  $controlledVocabEntry->setId($row['controlled_vocab_entry_id']);
63  $controlledVocabEntry->setSequence($row['seq']);
64 
65  $this->getDataObjectSettings('controlled_vocab_entry_settings', 'controlled_vocab_entry_id', $row['controlled_vocab_entry_id'], $controlledVocabEntry);
66 
67  return $controlledVocabEntry;
68  }
69 
74  function getLocaleFieldNames() {
75  return array('name');
76  }
77 
82  function updateLocaleFields(&$controlledVocabEntry) {
83  $this->updateDataObjectSettings('controlled_vocab_entry_settings', $controlledVocabEntry, array(
84  'controlled_vocab_entry_id' => $controlledVocabEntry->getId()
85  ));
86  }
87 
93  function insertObject(&$controlledVocabEntry) {
94  $this->update(
95  sprintf('INSERT INTO controlled_vocab_entries
96  (controlled_vocab_id, seq)
97  VALUES
98  (?, ?)'),
99  array(
100  (int) $controlledVocabEntry->getControlledVocabId(),
101  (float) $controlledVocabEntry->getSequence()
102  )
103  );
104  $controlledVocabEntry->setId($this->getInsertId());
105  $this->updateLocaleFields($controlledVocabEntry);
106  return $controlledVocabEntry->getId();
107  }
108 
114  function deleteObject($controlledVocabEntry) {
115  return $this->deleteObjectById($controlledVocabEntry->getId());
116  }
117 
123  function deleteObjectById($controlledVocabEntryId) {
124  $params = array((int) $controlledVocabEntryId);
125  $this->update('DELETE FROM controlled_vocab_entry_settings WHERE controlled_vocab_entry_id = ?', $params);
126  return $this->update('DELETE FROM controlled_vocab_entries WHERE controlled_vocab_entry_id = ?', $params);
127  }
128 
135  function getByControlledVocabId($controlledVocabId, $rangeInfo = null) {
136  $result =& $this->retrieveRange(
137  'SELECT * FROM controlled_vocab_entries WHERE controlled_vocab_id = ? ORDER BY seq',
138  array((int) $controlledVocabId),
139  $rangeInfo
140  );
141 
142  $returner = new DAOResultFactory($result, $this, '_fromRow');
143  return $returner;
144  }
145 
150  function updateObject(&$controlledVocabEntry) {
151  $returner = $this->update(
152  'UPDATE controlled_vocab_entries
153  SET controlled_vocab_id = ?,
154  seq = ?
155  WHERE controlled_vocab_entry_id = ?',
156  array(
157  (int) $controlledVocabEntry->getControlledVocabId(),
158  (float) $controlledVocabEntry->getSequence(),
159  (int) $controlledVocabEntry->getId()
160  )
161  );
162  $this->updateLocaleFields($controlledVocabEntry);
163  }
164 
168  function resequence($controlledVocabId) {
169  $result =& $this->retrieve(
170  'SELECT controlled_vocab_entry_id FROM controlled_vocab_entries WHERE controlled_vocab_id = ? ORDER BY seq',
171  array((int) $controlledVocabId)
172  );
173 
174  for ($i=1; !$result->EOF; $i++) {
175  list($controlledVocabEntryId) = $result->fields;
176  $this->update(
177  'UPDATE controlled_vocab_entries SET seq = ? WHERE controlled_vocab_entry_id = ?',
178  array(
179  (int) $i,
180  (int) $controlledVocabEntryId
181  )
182  );
183 
184  $result->MoveNext();
185  }
186 
187  $result->close();
188  unset($result);
189  }
190 
195  function getInsertId() {
196  return parent::getInsertId('controlled_vocab_entries', 'controlled_vocab_entry_id');
197  }
198 }
199 
200 ?>
config TEMPLATE inc php
Definition: config.inc.php:4
Operations for retrieving and modifying objects from a database.
Definition: DAO.inc.php:30
updateObject(&$controlledVocabEntry)
& retrieve($sql, $params=false, $callHooks=true)
Definition: DAO.inc.php:62
insertObject(&$controlledVocabEntry)
deleteObjectById($controlledVocabEntryId)
updateDataObjectSettings($tableName, &$dataObject, $idArray)
Definition: DAO.inc.php:412
updateLocaleFields(&$controlledVocabEntry)
& retrieveRange($sql, $params=false, $dbResultRange=null, $callHooks=true)
Definition: DAO.inc.php:152
Wrapper around ADORecordSet providing "factory" features for generating objects from DAOs.
getByControlledVocabId($controlledVocabId, $rangeInfo=null)
Operations for retrieving and modifying ControlledVocabEntry objects.
getDataObjectSettings($tableName, $idFieldName, $idFieldValue, &$dataObject)
Definition: DAO.inc.php:498
getById($controlledVocabEntryId, $controlledVocabId=null)
update($sql, $params=false, $callHooks=true, $dieOnError=true)
Definition: DAO.inc.php:186
Basic class describing a controlled vocab.