public function insert(DataInterface $data) { $creator = new RowCreator($this->table_name); $dirty_data = $data->getDirty(); if (empty($dirty_data)) { return true; } foreach ($dirty_data as $field => $value) { $creator->set($field, $value); } return $creator->create(); }
private function insert() { if (!$this->fresh) { return; } RowCreator::beginTransaction(); try { if ($this->beforeInsert() === false) { RowCreator::rollback(); return false; } $this->relation_ship->save(); $Entity = get_called_class(); (new Mapper())->selectTable($Entity::getTableName())->insert($this->data); $this->relation_ship->saveBridge(); RowCreator::commitTransaction(); } catch (\Exception $ex) { RowCreator::rollback(); $this->handleException($ex); return false; } return true; }