asgard / orm
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-11-09 16:06:41 UTC
README
#ORM
The ORM package gives you the possibility to store, fetch, search entities and define their relations to each other. It works with the Asgard Entity package.
##Installation If you are working on an Asgard project you don't need to install this library as it is already part of the standard libraries.
composer require asgard/orm 0.*
##Entity Relations
To define relations between entities, please read ORM Relations.
<?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
];
}
}
##Persistence
To persist and fetch entities, there are two options:
$dataMapper->save($entity);
ORMBehavior (ActiveRecord pattern)
$entity->save();
##ORM
The ORM class helps you construct queries to manipulate your stored entities. See the documentation.
$entities = $orm->where('position > ?', 5)->orderBy('title ASC')->get();
##Commands
List of commands that come with the ORM package.
###Contributing
Please submit all issues and pull requests to the asgardphp/asgard repository.
License
The Asgard framework is open-sourced software licensed under the MIT license