annoraaq / parrotdb
PHP对象数据库
dev-master
2020-12-29 17:17 UTC
Requires
- phpunit/phpunit: 5.3.2
This package is not auto-updated.
Last update: 2024-09-29 05:14:50 UTC
README
ParrotDb 是一个用 PHP 编写的开源对象数据库。
请注意,这是一个有趣的项目,并不打算用于生产环境。它更像是一个概念验证。不过,您可以查看 性能基准部分(位于 wiki),以了解其性能的第一印象。
ParrotDb 包含自己的 查询语言 以及自己的 文本文件格式。
安装
git clone https://github.com/Annoraaq/ParrotDb.git
composer install
运行测试
vendor/bin/phpunit
基本用法
假设我们有一个示例类
class Bird
{
public $id;
public $name;
}
现在我们需要创建一个会话、一个解析器和持久化管理器
$session = \ParrotDb\Core\PSessionFactory::createSession(
"Testfile",
\ParrotDb\Core\PSession::DB_XML
);
$parser = new \ParrotDb\Query\LotB\Parser\Parser($session->getDatabase());
$pm = $session->createPersistenceManager();
插入
$bird = new Bird();
$bird->id = 42;
$bird->name = "Pelecanidae";
$pm->persist($bird);
$pm->commit();
选择
$constraint = $parser->parse('get Bird id = 42');
$resultSet = $pm->query($constraint);
$fetchedBird = $resultSet->first();
更新
$constraint = $parser->parse('get Bird id = 42');
$resultSet = $pm->query($constraint);
$fetchedBird = $resultSet->first();
$fetchedBird->name = "Pidgeon";
$pm->commit();
删除
$constraint = $parser->parse('get Bird id = 42');
$pm->delete($constraint);