asgard / orm
v0.3.1
2016-05-13 11:31 UTC
Requires
- php: >=5.5.9
- asgard/common: ~0.3.0
- asgard/db: ~0.3.0
- asgard/entity: ~0.3.0
- asgard/migration: ~0.3.0
- asgard/validation: ~0.3.0
- doctrine/dbal: ^2.0
Requires (Dev)
- asgard/file: ~0.3.0
This package is not auto-updated.
Last update: 2024-09-14 15:29:04 UTC
README
#ORM
ORM包允许您存储、检索、搜索实体并定义它们之间的相互关系。它与Asgard Entity包一起工作。
##安装 如果您正在使用Asgard项目,您不需要安装这个库,因为它已经是标准库的一部分。
composer require asgard/orm 0.*
##实体关系
要定义实体之间的关系,请参阅ORM关系。
<?php
namespace Blog\Entities\Post;
class Post extends \Asgard\Entity\Entity {
public static function definition(\Asgard\Entity\Definition $definition) {
$definition->properties = [
'title',
'content',
'tags' => [
'type' => 'entity',
'entity' => 'Blog\Entities\Tag',
'many' => true
],
];
$definition->behaviors = [
new \Asgard\Orm\ORMBehavior
];
}
}
##持久化
要持久化和检索实体,有两种选项
$dataMapper->save($entity);
$entity->save();
##ORM
ORM类帮助您构建查询以操作存储的实体。查看文档。
$entities = $orm->where('position > ?', 5)->orderBy('title ASC')->get();
##命令
###贡献
请将所有问题和pull请求提交到asgardphp/asgard仓库。
许可证
Asgard框架是开源软件,采用MIT许可证。