asgard/orm

维护者

详细信息

github.com/asgardphp/orm

源代码

安装: 215

依赖: 1

建议: 1

安全: 0

星标: 0

关注者: 1

分支: 0

v0.3.1 2016-05-13 11:31 UTC

This package is not auto-updated.

Last update: 2024-09-14 15:29:04 UTC


README

#ORM

Build Status

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);

ORM行为(ActiveRecord模式)

$entity->save();

##ORM

ORM类帮助您构建查询以操作存储的实体。查看文档。

$entities = $orm->where('position > ?', 5)->orderBy('title ASC')->get();

##命令

ORM包附带的命令列表。

###贡献

请将所有问题和pull请求提交到asgardphp/asgard仓库。

许可证

Asgard框架是开源软件,采用MIT许可证