/** * 从数据库里删除领域模型数据 * * @param Data $data * @param IStorage $storage * @access public * @return integer affected row count */ protected function doDelete(Data $data, IStorage $storage = null, $collection = null) { $meta = $this->getMeta(); $adapter = $storage ?: $this->getStorage(); $table_name = $collection ?: $meta->getCollection(); $primary_key = $adapter->qcol($meta->getPrimaryKey()); return $adapter->delete($table_name, "{$primary_key} = ?", $data->id()); }
protected function doDelete(\Lysine\DataMapper\Data $data, IService $service = null, $collection = null) { $service = $service ?: $this->getService(); $collection = $collection ?: $this->getCollection(); return $service->delete($collection, $data->id()); }
protected function doDelete(\Lysine\DataMapper\Data $data, \Lysine\Service\IService $service = null, $collection = null) { $service = $service ?: $this->getService(); $collection = $collection ?: $this->getCollection(); list($where, $params) = $this->whereID($service, $data->id()); return $service->delete($collection, $where, $params); }
/** * 注册模型实例 * * @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); }
/** * 删除指定主键的数据 * * @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; }