Last year, I wrote a database conversion PHP class, the main reason was to assure conversion between different SQL versions, and generating portable SQL. At that time, I used it mainly to convert from Oracle to MySQL for local tests, then using ADODB it wasn’t difficult to make the code work with both databases.

A few months ago, I wrote another tool to make database usage Object Oriented. For example if I have a table “users” I can make inserts like this :

The current ADODB Objects Generator is using a MySQL database as its backend, but I’m using the generated code with an oracle database. You can easily configure it to work with others databases, but it’s not tested yet. The generated objects have almost the same structure using set and get methods for different fields, then four main methods, load, save, update and populate which respectively read data from a table, save data to a table, update fields, and populate objects with one entry from the table.

For example, to list the current active users :

Objects require ADODB, and there is also a patch system implemented because usually during the development you’ll need to add some specific methods to your object. Using patches, you can add a specific method to each generated object. For example, if your table name is a reserved word in PHP, you can change it with the patch from the download link.

To add a new method to any Object simply use the global variable $patch inside your patch file, then enter your method as a string.

Complete documentation is not yet available, but it’s not really that difficult to use. First download the Objects Generator, configure it, then run the index.php. Objects will be generated in the object folder. If you need any help about using the script please use our PHP Oracle Magazine Forum

Download ADODB Objects Generator 1.0.0