コード例 #1
0
 public function insert(Entity &$entity)
 {
     $dbFile = $this->dao->open($this->dbName);
     $items = $dbFile->read();
     if (count($items) > 0) {
         $last = $items->last();
         $insertId = $last['id'] + 1;
     } else {
         $insertId = 0;
     }
     $entity->setId($insertId);
     $item = $this->dao->createItem($entity->toArray());
     $items[] = $item;
     $dbFile->write($items);
 }