コード例 #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;
 }