save ( IcesDBObject  $object)

Saves an object to database.

This function will create a new entry either if the object has a field named is_new and set to bool TRUE or if it hasn't the id field. Otherwise it will update the record matching the id field.

Hace referencia a deleteRecordFromCache(), IcesDBObject\getRecord() y IcesDBObject\saveExtraData().

105  {
106  $record = $object->getRecord();
107  // Call save extra data to all implied objects.
108  // Don't loose the main reference!
109  $auxobject = $object;
110  $inner = NULL;
111  do {
112  $auxobject->saveExtraData();
113  $inner = $auxobject;
114  $auxobject = $auxobject->getParent();
115  } while ($auxobject != NULL && ($auxobject instanceof IcesDBObject));
116  // Decide between insert and update, and automatically populate temporal
117  // fields.
118  $record['modified'] = REQUEST_TIME;
119  if (empty($record['id']) || isset($object->is_new) && $object->is_new == TRUE) {
120  // Sometimes, like in exchange import, we are creating new objects
121  // with past dates.
122  if (empty($record['created'])) {
123  $record['created'] = REQUEST_TIME;
124  }
125  drupal_write_record($this->table, $record);
126  // Update the inserted object with the id parameter.
127  if (isset($record['id'])) {
128  $inner->id = $record['id'];
129  }
130  }
131  else {
132  drupal_write_record($this->table, $record, 'id');
133  }
134  $this->deleteRecordFromCache($record);
135  }
deleteRecordFromCache(array $record)
Deletes record from static cache.
Definition: common.db.logic.inc:302
saveExtraData()
Save object data.
Definition: common.db.logic.inc:444
getRecord()
Return object record.
Definition: common.db.logic.inc:391
Base class for all objects that are serializable with this framework.
Definition: common.db.logic.inc:383