Load many objects.
190 $order = ($order_field != NULL) ? $order_field : NULL;
191 if (!db_table_exists($this->table)) {
193 drupal_set_message(t(
'WARNING: CES table @table is missing. You probably need to reinstall CES.'), array(
'@table' => $this->table));
196 $query = db_select($this->table,
't')->fields(
't');
198 if (isset($conditions[
'createdsince'])) {
199 $query->condition(
't.created', $conditions[
'createdsince'],
'>=');
200 unset($conditions[
'createdsince']);
202 if (isset($conditions[
'createduntil'])) {
203 $query->condition(
't.created', $conditions[
'createduntil'],
'<=');
204 unset($conditions[
'createduntil']);
206 if (isset($conditions[
'join'])) {
207 $field = $conditions[
'join'][
'field'];
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']);
216 if (isset($conditions[
'limit'])) {
217 $query->range(0, $conditions[
'limit']);
218 unset($conditions[
'limit']);
220 if (isset($conditions[
'or'])) {
221 $orcondition = db_or();
222 foreach ($conditions[
'or'] as $orkey => $orvalue) {
223 $orcondition = $orcondition->condition(
't.' . $orkey, $orvalue);
225 $query->condition($orcondition);
226 unset($conditions[
'or']);
228 foreach ($conditions as $key => $value) {
229 $query->condition(
't.' . $key, $value);
231 if ($order != NULL) {
232 $query->orderBy($order, $order_type);
234 $result = $query->execute();
236 while (($record = $result->fetchAssoc()) !== FALSE) {
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