SimpleORM: PHP ORM classes and tools

SimpleOrm is a set of PHP classes to let you interact with tables and views in a database using an object oriented syntax (as the name implies it’s a simple PHP ORM).

Key features are:
1- Database abstraction
2- Query builder
3- Table-Model mapping
4- Fully iterable Resultsets

Database abstraction

Support for every kind of sql database can be added to the system simply creating a new adapter class extending the base one and a new resultsets class extended the base one: every functionality provided by the upper level classes (models, queries) uses a standard interface and doesn’t need to know low-level specs or the type of database in use.

At the moment only MySQL and MariaDB are supported out-of-the-box by the project.

Query Builder

To reach a really usable database abstraction SimpleORM provides a query builder to create queries (event quite complex ones) using an object oriented notation, with methods mapped to standard commands in SQL language.

Using the query builder you can create a query that can be translated to the correct SQL syntax in a transparent way, allowing you to port code from one database to another one by simply using/creating the correct adapter.

Table-Model mapping

Each table/view you want to use need to be “coded” as a model class, extending the base one and with public properties with the same name as table/view columns.

One you have defined a model you can:
– create a new record
– update a record
– delete a record
– delete records matchig a query
– count records matching a query
– find records matching a query
– find the first record matching a query

Fully iterable Resultsets

Results returned by calling the find() method of a Model are objects fully interable, so you can use foreach or you can jump to specific content using a seek call.

 

Project sources can be found here.

 

Leave a comment