loadCollection ( array  $conditions,
  $order_field = NULL,
  $order_type = 'ASC' 
)

Load many objects.

Parámetros
array$conditionsAssociative array with field names as keys. There are two special conditions for those objects having the created [time] field:
  • createdsince: the smaller created time to return.
  • createduntil: the largest created time to return.
string$order_fieldA field to order by.
string$order_typeDESC: Descending, ASC Ascending.
Devuelve
array Objects with attribute $key = $value ordered by $order field.
189  {
190  $order = ($order_field != NULL) ? $order_field : NULL;
191  if (!db_table_exists($this->table)) {
192  // This prevents a fatal error in case CES table is gone.
193  drupal_set_message(t('WARNING: CES table @table is missing. You probably need to reinstall CES.'), array('@table' => $this->table));
194  return FALSE;
195  }
196  $query = db_select($this->table, 't')->fields('t');
197  // Handle special conditions.
198  if (isset($conditions['createdsince'])) {
199  $query->condition('t.created', $conditions['createdsince'], '>=');
200  unset($conditions['createdsince']);
201  }
202  if (isset($conditions['createduntil'])) {
203  $query->condition('t.created', $conditions['createduntil'], '<=');
204  unset($conditions['createduntil']);
205  }
206  if (isset($conditions['join'])) {
207  $field = $conditions['join']['field'];
208  $s = new IcesSerializer($conditions['join']['class']);
209  $table = $s->table;
210  $condition_field = $conditions['join']['condition']['field'];
211  $condition_value = $conditions['join']['condition']['value'];
212  $query->join($table, 'j', 't.' . $field . ' = ' . 'j.id AND j.' .
213  $condition_field . ' = :val', array(':val' => $condition_value));
214  unset($conditions['join']);
215  }
216  if (isset($conditions['limit'])) {
217  $query->range(0, $conditions['limit']);
218  unset($conditions['limit']);
219  }
220  if (isset($conditions['or'])) {
221  $orcondition = db_or();
222  foreach ($conditions['or'] as $orkey => $orvalue) {
223  $orcondition = $orcondition->condition('t.' . $orkey, $orvalue);
224  }
225  $query->condition($orcondition);
226  unset($conditions['or']);
227  }
228  foreach ($conditions as $key => $value) {
229  $query->condition('t.' . $key, $value);
230  }
231  if ($order != NULL) {
232  $query->orderBy($order, $order_type);
233  }
234  $result = $query->execute();
235  $loads = array();
236  while (($record = $result->fetchAssoc()) !== FALSE) {
237  $loads[] = $this->loadFromRecord($record);
238  }
239  return $loads;
240  }
Loads and saves to db objects of class IcesDBObject.
Definition: common.db.logic.inc:17
loadFromRecord($record)
Loads a IcesDBObject from it record.
Definition: common.db.logic.inc:80