/** * 删除指定主键的数据 * * @param Data $data * @param IStorage $storage * @access protected * @return boolean */ protected function doDelete(Data $data, IStorage $storage = null, $collection = null) { $meta = $this->getMeta(); $this->getStorage()->remove($meta->getCollection(), array($meta->getPrimaryKey() => $data->id()), array('justOne' => true, 'safe' => true)); return true; }
/** * 注册模型实例 * * @param mixed $obj * @static * @access public * @return boolean */ public static function set(Data $obj) { if (!self::$enabled) { return true; } $id = $obj->id(); if (!$id) { return false; } $class = get_class($obj); $key = $class . $id; listen_event($obj, Data::AFTER_DELETE_EVENT, function () use($class, $id) { Registry::remove($class, $id); }); return Utils\Registry::set($key, $obj); }