2017 © Pedro Peláez
 

library repository

A small repository layer.

image

olajoscs/repository

A small repository layer.

  • Saturday, April 1, 2017
  • by olajoscs
  • Repository
  • 1 Watchers
  • 0 Stars
  • 20 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 2 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Repository

This is a minimal Model/Repository package based on the QueryBuilder package. Minimum requirements: PHP 5.5+ with the requirements of the QueryBuilder., (*1)

Model

To create a model which is handled by the repository, simply extend the Model class., (*2)

use OlajosCs\Repository\Model;
class MyModel extends Model {}

Then 3 methods has to be defined in the model: - validate(): returns void, which should throw a ValidationExcpetion when an object is not completely ready to put into the database, - static getTableName(): returns string, the name of the database table, which is related to the model, - static getIdField(): returns string, which defines what the name of the ID field is in the database table., (*3)

Repository

To create a repository which handles the model objects, simply extend the Repository class., (*4)

use OlajosCs\Repository\Repository
class MyObjectRepository extends Repository {}

There is only one method, which has to be defined: - getModelClass(): string, returns the name of the class, which is the model. (MyModel::class), (*5)

Functionality

  • create(): Return a new, empty model
  • get($id): Return a model, which has the ID of $id. If it does not exist, exception is thrown.
  • getOrNew($id): Return a model, which has the ID of $id. If it does not exist, then a new empty one is returned.
  • getList(): Return an array of all the models available in the database.
  • save(Model $model): Save the model into the database. Create or update.
  • delete(Model $model): Delete the model from the database.
  • getWhereIdIn(array $ids): Return an array of the models, which have the ID listed in the array.
  • getWhereIdInWithKeys(array $ids): Same as getWhereIdIn($ids), but the key of the returned array is the ID of the model.

The Versions

01/04 2017

dev-master

9999999-dev https://github.com/olajoscs/Repository

A small repository layer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Csaba Olajos

01/04 2017

1.0.0

1.0.0.0 https://github.com/olajoscs/Repository

A small repository layer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Csaba Olajos