예제 #1
0
 public function test()
 {
     $this->setAttributes(['id' => ['type' => 'uuid', 'primary_key' => true]]);
     $id = '710c825e-20ea-4c98-b313-30d9eec2b2dc';
     $class = $this->class;
     $data = new $class(['id' => $id]);
     $registry = Registry::getInstance();
     $this->assertFalse((bool) $registry->get($class, $data->id(true)));
     $data->save();
     $this->assertFalse((bool) $registry->get($class, $data->id(true)));
     $data = $class::find($id);
     $this->assertTrue((bool) $registry->get($class, $data->id(true)));
     $data->destroy();
     $this->assertFalse((bool) $registry->get($class, ['id' => $id]));
 }
예제 #2
0
파일: Mapper.php 프로젝트: tempbottle/owl
 /**
  * 删除Data
  *
  * @param Data $data
  * @return boolean
  */
 public function destroy(Data $data)
 {
     if ($this->isReadonly()) {
         throw new \RuntimeException($this->class . ' is readonly');
     }
     if ($data->isFresh()) {
         return true;
     }
     $this->__before('delete', $data);
     if (!$this->doDelete($data)) {
         throw new \Exception($this->class . ' destroy failed');
     }
     $this->__after('delete', $data);
     Registry::getInstance()->remove($this->class, $data->id());
     return true;
 }