2017 © Pedro PelĆ”ez
 

library jetorm

ORM for Nette\Database based on uestla\yetorm

image

artfocus/jetorm

ORM for Nette\Database based on uestla\yetorm

  • Thursday, October 6, 2016
  • by hranicka
  • Repository
  • 0 Watchers
  • 0 Stars
  • 8,528 Installations
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 23 Versions
  • 0 % Grown

The README.md

ATTENTION:

THIS PACKAGE IS NOT A THING YOU WANT TO WORK WITH.

PLEASE DO NOT USE IT IF YOU HAVE AN OPTION.

USE DOCTRINE 2 INSTEAD. REALLY. IT SAVES YOUR NERVES.

Artfocus\JetORM

Lightweight ORM built on top of Nette\Database. Based on uestla/yetorm, hranicka/yetorm. THANK YOU!, (*1)

Quickstart

Consider following database schema:, (*2)

Database schema, (*3)

Installation

Setup config.neon like this:, (*4)

extensions:
    jetorm: Artfocus\JetORM\Extension

yetorm:
    # setup cache IStorage for better performance
    # setup this only on production otherwise Entity doesn't load new Reflection until cache will be deleted!
    storage: cacheStorage # for development, leave this value empty (without "cacheStorage")

Entities

Firstly we'll create entity classes according to the schema above. There are two ways of defining entity properties - via @property[-read] annotation, or simply via getter and setter., (*5)

Tag

/**
 * @property-read int|null $id
 * @property string $name
 *
 * @method int|null getId()
 * @method string getName()
 *
 * @method Tag setName(string $name)
 */
class Tag extends Artfocus\JetORM\Entity
{

}

Author

/**
 * @property-read int|null $id
 * @property string $name
 * @property string $web
 * @property \DateTime $born
 *
 * @method int|null getId()
 * @method string getName()
 * @method string getWeb()
 * @method \DateTime getBorn()
 *
 * @method Author setName(string $name)
 * @method Author setWeb(string $web)
 * @method Author setBorn(\DateTime $born)
 */
class Author extends Artfocus\JetORM\Entity
{

}

Book

There are some relations at the Book entity - two N:1 Author and M:N Tag relations. Every Artfocus\JetORM\Entity has an instance of Artfocus\JetORM\Row in it, which is a simple wrapper around Nette\Database\Table\ActiveRow. That means that we can access related rows or column values through it., (*6)

/**
 * @property-read int|null $id
 * @property string $title
 * @property string $web
 * @property string $slogan
 * @property Author $author -> :one(author)
 * @property Author $maintainer -> :one(author, maintainer_id)
 * @property-read Tag[]|Artfocus\JetORM\Collection $tags -> :many(book_tag, tag)
 *
 * @method int|null getId()
 * @method string getTitle()
 * @method string getWeb()
 * @method string getSlogan()
 * @method Author getAuthor()
 * @method Author getMaintainer()
 * @method Tag[]|Artfocus\JetORM\Collection getTags()
 *
 * @method Book setTitle(string $title)
 * @method Book setWeb(string $web)
 * @method Book setSlogan(string $slogan)
 * @method Book setAuthor(Author $author)
 * @method Book setMaintainer(Author $maintainer)
 */
class Book extends Artfocus\JetORM\Entity
{

}

The M:N relation is realized with Artfocus\JetORM\Collection instance, default Artfocus\JetORM\EntityCollection - which is a lazy collection of entities., (*7)

Repositories

Every repository has to have table and entity class name defined - either via @table and @entity annotation, or via protected $table and $entity class property., (*8)

/**
 * @table book
 * @entity Book
 */
class BookRepository extends Artfocus\JetORM\Repository
{

}

Persisting

To persist changes we make simply call $repository->persist($entity)., (*9)

$book->setWeb('http://example.com');
$books->persist($book);

And that's it!, (*10)

Additional notes

  • No identity map
  • Query efficiency - the collections (resp. Artfocus\JetORM\Row) use the power of Nette\Database efficiency
  • Collection operations - collections can be sorted via $coll->orderBy($column, $dir) and limited via $coll->limit($limit, $offset)

More

For more examples please see the tests., (*11)

The Versions

06/10 2016

dev-master

9999999-dev https://bitbucket.org/artfocus/jetorm

ORM for Nette\Database based on uestla\yetorm

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jaroslav Hranička

orm database nette yetorm

06/10 2016
29/06 2016
21/06 2016
26/05 2016
16/05 2016
13/05 2016
13/05 2016
01/02 2016
28/01 2016
13/01 2016
13/01 2016
13/01 2016
11/01 2016

v3.2.0

3.2.0.0 https://bitbucket.org/artfocus/jetorm

ORM for Nette\Database based on uestla\yetorm

  Sources   Download

MIT

The Requires

 

The Development Requires

orm database nette yetorm

11/01 2016

v3.1.2

3.1.2.0 https://bitbucket.org/artfocus/jetorm

ORM for Nette\Database based on uestla\yetorm

  Sources   Download

MIT

The Requires

 

The Development Requires

orm database nette yetorm

06/01 2016

v3.1.1

3.1.1.0 https://bitbucket.org/artfocus/jetorm

ORM for Nette\Database based on uestla\yetorm

  Sources   Download

MIT

The Requires

 

The Development Requires

orm database nette yetorm

07/10 2015

v3.1.0

3.1.0.0 https://bitbucket.org/artfocus/jetorm

ORM for Nette\Database based on uestla\yetorm

  Sources   Download

MIT

The Requires

 

The Development Requires

orm database nette yetorm

07/10 2015

v3.0.1

3.0.1.0 https://bitbucket.org/artfocus/jetorm

ORM for Nette\Database based on uestla\yetorm

  Sources   Download

MIT

The Requires

 

The Development Requires

orm database nette yetorm

05/10 2015

v3.0.0

3.0.0.0 https://bitbucket.org/artfocus/jetorm

ORM for Nette\Database based on uestla\yetorm

  Sources   Download

MIT

The Requires

 

The Development Requires

orm database nette yetorm

05/10 2015

v2.0.2

2.0.2.0 https://bitbucket.org/artfocus/jetorm

ORM for Nette\Database based on uestla\yetorm

  Sources   Download

MIT

The Requires

 

The Development Requires

orm database nette yetorm

01/10 2015

v2.0.1

2.0.1.0 https://bitbucket.org/artfocus/jetorm

ORM for Nette\Database based on uestla\yetorm

  Sources   Download

MIT

The Requires

 

The Development Requires

orm database nette yetorm

01/10 2015

v2.0.0

2.0.0.0 https://bitbucket.org/artfocus/jetorm

ORM for Nette\Database based on uestla\yetorm

  Sources   Download

MIT

The Requires

 

The Development Requires

orm database nette yetorm

15/09 2015

v1.0.0

1.0.0.0 https://bitbucket.org/artfocus/jetorm

ORM for Nette\Database based on uestla\yetorm

  Sources   Download

MIT

The Requires

 

The Development Requires

orm database nette yetorm