/** * This function updates or inserts the artefact. This involves putting * some data in the artefact table (handled by parent::commit()), and then * some data in the artefact_file_files table. */ public function commit() { // Just forget the whole thing when we're clean. if (empty($this->dirty)) { return; } // We need to keep track of newness before and after. $new = empty($this->id); // Commit to the artefact table. parent::commit(); // Reset dirtyness for the time being. $this->dirty = true; $data = (object) array('artefact' => $this->get('id'), 'size' => $this->get('size'), 'oldextension' => $this->get('oldextension'), 'fileid' => $this->get('fileid'), 'filetype' => $this->get('filetype')); if ($new) { if (empty($data->fileid)) { $data->fileid = $data->artefact; } insert_record('artefact_file_files', $data); } else { update_record('artefact_file_files', $data, 'artefact'); } $this->dirty = false; }