rrelmy/rorm

Simple lightweight ORM

1.0.0 2016-02-21 17:34 UTC

This package is not auto-updated.

Last update: 2024-09-14 17:48:20 UTC


README

Build Status Code Coverage Scrutinizer Code Quality

Build Status

Requirements

  • PHP 5.3

PHP 5.3 requires a JsonSerializable polyfill for the Model.

With PHP 5.5 we could ditch the QueryIterator and use yield. Yield seems to have a little bit bigger memory footprint.

Goals

  • Easy to use, easy to extend
  • Minimalistic ORM
  • Fast and low memory footprint
  • compound key support
  • Almost 100% test code coverage

TODO

  • check for possible model loaded hook
  • check if autoId could be ditched
  • consider setExpr (may be bad because until the model is loaded again the data is 'weird')
  • grouping/having support inside the QueryBuilder
  • Documentation

Ideas

  • Cache

Usage

General

Model

QueryBuilder

Relations

There is no special support for relationships, but its easy to integrate them yourself.

Error handling

It is recommended to use the PDO exception error mode. Rorm has no special error handling and does not catch thrown PDOException's!

$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

Unbuffered queries

You can use unbuffered queries with the findMany method, but you have to be aware that no queries can be executed until the iteration is finished.

No special methods are supplied for configure unbuffered queries. You may use the PDO attributes yourself.

Multiple database connections

You can add multiple database connections to the Rorm config with the setDatabase($dbh, 'name') method.

Each model can have a different database connection which can be configure with the $_connection property.