Revision 1
This is the first revision of MySimpleORM. There is a long way to go before this little tool is considered secure and reliable but this first revision contains the following :
- Database abstraction layer, let's you do CRUD operations without having to write any SQL code.
- The object mapping interface, declaring all the methods of the object mapping class.
- The object mapping class which defines how to do any CRUD operations with a PHP object
- Lastly, the BaseClass class which extends any of your PHP object classes. It includes method to quickly insert, delete, update or select elements of a table.
To be able to use the ORM, you need to have a PHP application and a MySQL database. The requirements are quite simple. Create your object classes following this simple guideline.
- Your PHP class must have the same name as your table. For instance; to be able to use your class "Users" you must have a table named "Users" in your MySQL schema.
- Make sure to require the "BaseClass.php" file in your class and then extend your class with it.
- Make sure that your class attributes are all equivalent to your table columns and ensure that they all have the same name.
- Create your getters/setters.
- Read the documentation (soon to be available) to understand how to select/update/delete/insert objects to your DB.
- Don't forget to modify the "Database.php" class with your database information.
Example of a class
require_once("BaseClass.php");
class your_class extends BaseClass {
public $IDyour_class;
public $Name;
public __construct() {
$this->IDyour_class = 0;
$this->Name = "";
}
public __destruct() {}
public getIDyour_class() {
return $this->IDyour_class;
}
public getName() {
return $this->Name;
}
public setName($id) {
$this->IDyour_class = $id;
}
public setName($n) {
$this->Name = $n;
}
}