예제 #1
0
파일: Mapper.php 프로젝트: hackyoung/leno
 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();
 }
예제 #2
0
파일: Entity.php 프로젝트: hackyoung/leno
 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;
 }