2017 © Pedro Peláez
 

library orm

image

asgard/orm

  • Saturday, February 17, 2018
  • by leyou
  • Repository
  • 1 Watchers
  • 0 Stars
  • 205 Installations
  • PHP
  • 1 Dependents
  • 1 Suggesters
  • 0 Forks
  • 1 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

ORM

Build Status, (*1)

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., (*2)

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., (*3)

composer require asgard/orm 0.*

Entity Relations

To define relations between entities, please read ORM Relations., (*4)

<?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:, (*5)

Data Mapper, (*6)

$dataMapper->save($entity);

ORMBehavior (ActiveRecord pattern), (*7)

$entity->save();

ORM

The ORM class helps you construct queries to manipulate your stored entities. See the documentation., (*8)

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

Commands

List of commands that come with the ORM package., (*9)

Contributing

Please submit all issues and pull requests to the asgardphp/asgard repository., (*10)

License

The Asgard framework is open-sourced software licensed under the MIT license, (*11)

The Versions