function end($tag, $attributes, $cdata) { if (!$this->table) { return; } switch ($tag) { case 'row': if ($this->record && !$this->record->isLoaded()) { $exist = false; if ($fields = $this->record->getTable()->_checkUnique) { $where = array(); foreach ($fields as $f) { $where[$f] = isset($this->record->{$f}) ? $this->record->{$f} : null; } $records = $this->record->getTable()->findBy($where); $exist = (bool) count($records); } if (!$exist) { $this->record->insert(); } } $this->record = null; break; case 'field': if (!empty($this->record)) { $this->record->set($attributes['name'], $cdata); } break; } }
function delete() { $this->record->getAdapter()->query("DELETE FROM ?_data WHERE `table`=? AND `id`=?", $this->record->getTable()->getName(true), $this->record->pk()); $this->data = array(); $this->changedFields = array(); $this->blobData = array(); $this->blobFields = array(); $this->deletedFields = array(); $this->isLoaded = true; }