Understand the internals

Porte has been tested with PHP 5.2.3 and MySQL 5.0.45 (MySQL Community Server). It should work with any version of PHP superior to 5.2.x and of MySQL version superior to 5.0.x

How does it work

The abstract class PorteRecord provides a set of predefined methods. Furthermore, it dynamically adds properties and methods thanks to the "__get" and "__call" methods provided by PHP 5. You may overwrite each dynamic methods based on your needs.

Note, PorteRecord does not define any other methods, it means it is safe to define __construct, __destruct, __set or any other methods provided by PHP.

Datas are stored in two arrays which are $attributes and $associations. When you call the method toArray, it is the values present in those arrays which are returned.

Configuring your objects

The abstract class PorteRecord will adapt its behavior based on the configuration you provide in two arrays: $meta_table and $meta_fields.

The $meta_table array

It is used to define and configure the table associated to a given class. All keys are optional. The array allow you to overwrite the name of the table, its primary key and its encoding.

The $meta_fields array

It is used to define the configuration field by field. It is designed to be as minimalist as possible.

Open Source Object Relational Mapping in PHP

Download Porte 0.2.0