ORM
ORM?!
ORM = Object Relational Mapper
- Transforme les lignes de la BDD en objets
- Gère les liens entre ces objets
Mais encore?
S'affranchir de SQL pour gérer sa BDD via la POO.
Des exemples pour PHP
- Doctrine
- Idiorm
Exemple : Idiorm
Installation, configuration : RTFM
// Read
$person = ORM::for_table('person')->where('name', 'Fred Bloggs')->find_one();
$person = ORM::for_table('person')->find_one(5);
$people = ORM::for_table('person')->find_many();
// Update
$person = ORM::for_table('person')->where('name', 'Fred Bloggs')->find_one();
$person->age = 20;
$person->save();
//Create
$person = ORM::for_table('person')->create();
$person->name = 'Joe Bloggs';
$person->age = 40;
$person->save();
// Delete
$person = ORM::for_table('person')->find_one(5);
$person->delete();
$person = ORM::for_table('person')
->where_equal('zipcode', 55555)
->delete_many();
$name_has_changed = $person->is_dirty('name'); // Returns true or false
ORM
By LauDev
ORM
- 504