php

If you have followed my previous tutorial, then you already know about, how to create object relational mapping  (ORM) in object oriented programming system.  Before proceed, you can go through this at least once. Here is the link ORM PHP using OOP

In this tutorial, we will be developing application which generates entities automatically either of a single table or whole tables at once. Lets begin together…

1.  First, we create three files,

 

2. db.config.php, contains database settings either for testing or production environment

 

3. entitygenerator.php,

Here, we have defined certains variables, entitty variables array, entity class, base class, primary keys, autoincrement keys, tables and tags variables.

getEntity() function actually generates the entity for single table whereas getEntitities() generates entities for whole tables in the given database. Finally, we are writing the generated classes in entities folder.

4. generate.php,

 

Here, we included all the necessary files, connected to the database and finally generated the entities. The generated entities are in the format that fits to our previous ORM application.

I hope this completes the ORM tutorial. In next tutorial, we will looking, how to automatically generate PHP classes from web service or WSDL file and ready to work code. So, stayed tune..have a good programming life ahead!!

Download the source code from here orm-php.zip