ORM fini (pour l'instant)

This commit is contained in:
xdrm-brackets 2016-07-24 18:23:09 +02:00
parent 1ff04be983
commit fd04fb2593
2 changed files with 33 additions and 28 deletions

View File

@ -829,10 +829,6 @@
/* (2) On compose la requête */ /* (2) On compose la requête */
$requestString = SQLBuilder::BUILD($requestS).';'; $requestString = SQLBuilder::BUILD($requestS).';';
// var_dump($requestString);
// var_dump($binded);
// exit();
/* (3) On prépare la requête */ /* (3) On prépare la requête */
$request = Database::getPDO()->prepare($requestString); $request = Database::getPDO()->prepare($requestString);

View File

@ -345,25 +345,34 @@
/* [1] FETCH /* [1] FETCH
=========================================================*/ =========================================================*/
// $warehouse = $warehouse =
// Table::get('warehouse') // Access to table 'warehouse' Table::get('warehouse') // Table : WAREHOUSE
// ->whereName(['stef-montauban', Rows::COND_EQUAL]) // condition : name = 'my-warehouse' ->whereName(['stef-montauban', Rows::COND_EQUAL]) // condition : name = 'stef-montauban'
// ->select('name'); ->select('name') // select : warehouse.name
->unique(); // limit : 1
$myUser =
Table::get('user') // Table : USER
->whereId([100, Rows::COND_INF]) // condition : clé primaire(id_user) < 100
->whereId([[94, 95, 96], Rows::COND_IN]) // condition : clé primaire(id_user) parmi les valeurs [94, 95, 96]
->whereUsername(['%e%', Rows::COND_LIKE]) // condition : username LIKE '%e%'
->select(['mail', 'username', 'firstname']) // select : user.mail, user.username, user.firstname
->select('id_user') // Select : user.id_user
->join('id_warehouse', $warehouse) // jointure la table WAREHOUSE (automatique, soit référence, soit primaire soit même référence)
// SELECT
->fetch();
var_dump($myUser);
// SELECT user.firstname, user.mail, user.username, user.id_user, warehouse.name
// FROM user, (SELECT warehouse.* FROM warehouse WHERE warehouse.name = :warehouse_x_name_0 ) as warehouse
// WHERE user.id_user < :user_x_id_user_0
// AND user.id_user IN (:user_x_id_user_1_0, :user_x_id_user_1_1)
// AND user.username LIKE :user_x_username_2
// AND user.id_warehouse = warehouse.id_warehouse
// //
// // LIMIT 1;
// $myUser =
// Table::get('user') // Access to table 'user'
// ->whereId([100, Rows::COND_INF]) // PRIMARY KEY (other condition on same field)
// ->whereId([[94, 95], Rows::COND_IN]) // PRIMARY KEY (other condition on same field)
// ->whereUsername(['%', Rows::COND_LIKE]) // Dynamic getter 'getByMySuperColumn' -> 'my_super_column'
// ->select(['mail', 'username', 'firstname']) // Select clause
// ->select('id_user') // Select clause (added)
// ->join('id_warehouse', $warehouse) // joins warehouse (with name 'my-warehouse') to column 'id_warehouse'
// ->unique() // unique result
//
// // SELECT
// // ->fetch();
// var_dump($myUser);
/* [2] Modification /* [2] Modification
=========================================================*/ =========================================================*/
@ -439,21 +448,21 @@
// $warehouse = Table::get('warehouse') // $warehouse = Table::get('warehouse')
// ->whereName(['stef%', Rows::COND_LIKE]); // ->whereName(['stef%', Rows::COND_LIKE])
// ->select('id_warehouse');
// //
// $module_merge = Table::get('module_merge') // $module_merge = Table::get('module_merge')
// ->join('id_warehouse', $warehouse); // ->join('id_warehouse', $warehouse)
// ->select('id_module_merge');
// //
// $module = Table::get('module') // $module = Table::get('module')
// ->join('id_module', $module_merge); // ->join('id_module', $module_merge)
// ->select('id_module');
// //
// $chip = Table::get('chip') // $chip = Table::get('chip')
// ->select('id_chip') // ->select('id_chip')
// ->join('id_module', $module); // ->join('id_module', $module);
// //
// // $chip = Table::get('chip')
// // ->join('id_module', $module_merge)
//
// var_dump($chip->fetch()); // var_dump($chip->fetch());
// SELECT module.id_module // SELECT module.id_module