Skip to content

Releases: anthonygauthier/MySimpleORM

2.1.5

01 Apr 17:29
4c9c8bc
Compare
Choose a tag to compare
Removed "selecting" trae

2.1.4

01 Apr 17:23
50811c1
Compare
Choose a tag to compare
Cleaned up constructor

2.1.3

01 Apr 16:23
5d8cff1
Compare
Choose a tag to compare
Let PHP take care of type comparison

Revision 1.0.1

03 May 19:53
Compare
Choose a tag to compare
  • Added support for inner joins, the database abstraction layer and the object mapping implementation will find the foreign keys and create the necessary INNER JOIN to the query sent to the database.
  • Minor bug fixes
  • Fixed errors in the documentation

Revision 1

28 Apr 19:59
Compare
Choose a tag to compare

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.

  1. 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.
  2. Make sure to require the "BaseClass.php" file in your class and then extend your class with it.
  3. Make sure that your class attributes are all equivalent to your table columns and ensure that they all have the same name.
  4. Create your getters/setters.
  5. Read the documentation (soon to be available) to understand how to select/update/delete/insert objects to your DB.
  6. 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;  
  }
}