NotORM

Simply read relationships from database

OSI Days 2010

by Jakub Vrána – vrana@php.net

About the Speaker

NotORM Philosophy

What is NotORM?

Easy and efficient access to database data

Uses PDO (tested with MySQL, SQLite, PostgreSQL, MS SQL, Oracle)

Free even for commercial use (Apache license)

www.notorm.com

Live demo

There is also a version for Dibi.

Convenient API

Classes diagram

Database

Result

Row

Live demo

Repetitive calls of where, order and select are possible – it will append values to the previous calls (where by AND). These methods plus limit provide a fluent interface so $table->where()->order()->limit() is possible (in any order). All methods are lazy – the query is not executed until necessary.

$row["author_id"] gets the numerical value of column, $row->author gets row representing the author from the table of authors.

$row->$tableName() builds "SELECT * FROM $tableName WHERE {$myTable}_id = $row[$primary]". The returned object can be customized as usual table results (with order, limit, ...) and then executed. All results are lazy and execute only a single query for each set of rows.

Efficiency

  1. Constant number of queries
  2. Only required columns are transferred
  3. No caching involved, fast by its nature
  4. Best utilization of MySQL query cache

Live demo

Column Names

Persistency

Available in separate branch

The $array parameter holds column names in keys and data in values. Values are automatically quoted, SQL literals can be passed as objects of class NotORM_Literal, for example:

Cache

Stores only the information about used columns, no data

Weaknesses

Why NotORM?

Questions?

Thank you