Corrections des repositories pour la nouvelle version de Rows::select(ONLY_ONE_FIELD)

This commit is contained in:
xdrm-brackets 2016-07-25 01:14:35 +02:00
parent 547fc5449c
commit 25f8eb6963
6 changed files with 36 additions and 48 deletions

View File

@ -881,7 +881,6 @@
/* (2) On compose la requête */ /* (2) On compose la requête */
$requestString = SQLBuilder::BUILD($requestS).';'; $requestString = SQLBuilder::BUILD($requestS).';';
var_dump($requestString);
/* (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

@ -80,13 +80,13 @@
/* [5] On ajoute la action /* [5] On ajoute la action
=========================================================*/ =========================================================*/
/* (1) On effectue l'insertion */ /* (1) On effectue l'insertion */
$insert = Database::getPDO()->prepare("INSERT INTO action_merge(id_action_merge, id_target, id_source, id_action) $inserted = Table::get('action_merge')
VALUES(DEFAULT, :id_target, :id_source, :id_action)"); ->insert([
$inserted = $insert->execute([ 'id_action_merge' => Rows::INSERT_DEFAULT,
':id_target' => $id_target, 'id_target' => $id_target,
':id_source' => $id_source, 'id_source' => $id_source,
':id_action' => $id_action 'id_action' => $id_action
]); ]);
/* (2) Si erreur SQL, on retourne une erreur */ /* (2) Si erreur SQL, on retourne une erreur */
if( !$inserted ) if( !$inserted )
@ -138,17 +138,13 @@
/* [2] On supprime la action /* [2] On supprime la action
=========================================================*/ =========================================================*/
/* (1) On effectue la suppression */ /* (1) On effectue la suppression */
$delete = Database::getPDO()->prepare("DELETE FROM action_merge $deleted = Table::get('action_merge')
WHERE id_action_merge = :id_action_merge ->whereId($existingId)
AND id_target = :id_target ->whereIdTarget($id_target)
AND id_source = :id_source ->whereIdSource($id_source)
AND id_action = :id_action"); ->whereIdAction($id_action)
$deleted = $delete->execute([ ->unique()
':id_action_merge' => $existingId, ->delete();
':id_target' => $id_target,
':id_source' => $id_source,
':id_action' => $id_action
]);
/* (2) Si erreur SQL, on retourne une erreur */ /* (2) Si erreur SQL, on retourne une erreur */
if( !$deleted || self::getById($existingId) !== false ) if( !$deleted || self::getById($existingId) !== false )

View File

@ -20,20 +20,19 @@
public static function getAll($id_warehouse){ public static function getAll($id_warehouse){
/* [1] On récupère les modules de l'entrepot courant /* [1] On récupère les modules de l'entrepot courant
=========================================================*/ =========================================================*/
$module = Table::get('module') $module_merge = Table::get('module_merge')
->whereName([ $_SESSION['WAREHOUSE']['modules'], Rows::COND_IN ]); ->whereIdWarehouse(7);
$chip = Table::get('chip') $chip = Table::get('chip')
->join('id_module', $module_merge)
->select('*'); ->select('*');
$module_merge = Table::get('module_merge')
->join('id_module', $module);
// var_dump($module_merge->fetch());
/* [2] On retourne le résultat /* [2] On retourne le résultat
=========================================================*/ =========================================================*/
return $chip->fetch();
} }
} }

View File

@ -180,7 +180,8 @@
$machine = Table::get('machine') $machine = Table::get('machine')
->whereId($id_machine) ->whereId($id_machine)
->whereIdWarehouse($id_warehouse) ->whereIdWarehouse($id_warehouse)
->select(['id_machine', 'name']) ->select('id_machine')
->select('name')
->unique(); ->unique();
return $machine->fetch(); return $machine->fetch();
@ -209,7 +210,8 @@
$machine = Table::get('machine') $machine = Table::get('machine')
->whereName($name) ->whereName($name)
->whereIdWarehouse($id_warehouse) ->whereIdWarehouse($id_warehouse)
->select(['id_machine', 'name']) ->select('id_machine')
->selcet('name')
->unique(); ->unique();
return $machine->fetch(); return $machine->fetch();
@ -238,7 +240,8 @@
$machine = Table::get('machine') $machine = Table::get('machine')
->whereToken($token) ->whereToken($token)
->whereIdWarehouse($id_warehouse) ->whereIdWarehouse($id_warehouse)
->select(['id_machine', 'name']) ->select('id_machine')
->select('name')
->unique(); ->unique();
return $machine->fetch(); return $machine->fetch();
@ -264,7 +267,8 @@
=========================================================*/ =========================================================*/
$machine = Table::get('machine') $machine = Table::get('machine')
->whereIdWarehouse($id_warehouse) ->whereIdWarehouse($id_warehouse)
->select(['id_machine', 'name']); ->select('id_machine')
->select('name');
return $machine->fetch(); return $machine->fetch();
} }

View File

@ -218,7 +218,7 @@
$user = Table::get('user') $user = Table::get('user')
->whereIdWarehouse($id_warehouse) ->whereIdWarehouse($id_warehouse)
->whereIdUser($id_user) ->whereIdUser($id_user)
->select(['id_user', 'code', 'username', 'firstname', 'lastname', 'mail']) ->select('*')
->unique(); ->unique();
return $user->fetch(); return $user->fetch();
@ -246,7 +246,7 @@
$user = Table::get('user') $user = Table::get('user')
->whereIdWarehouse($id_warehouse) ->whereIdWarehouse($id_warehouse)
->whereCode($code) ->whereCode($code)
->select(['id_user', 'code', 'username', 'firstname', 'lastname', 'mail']) ->select('*')
->unique(); ->unique();
return $user->fetch(); return $user->fetch();
@ -274,7 +274,7 @@
$user = Table::get('user') $user = Table::get('user')
->whereIdWarehouse($id_warehouse) ->whereIdWarehouse($id_warehouse)
->whereUsername($username) ->whereUsername($username)
->select(['id_user', 'code', 'username', 'firstname', 'lastname', 'mail']) ->select('*')
->unique(); ->unique();
return $user->fetch(); return $user->fetch();
@ -299,7 +299,7 @@
=========================================================*/ =========================================================*/
$user = Table::get('user') $user = Table::get('user')
->whereIdWarehouse($id_warehouse) ->whereIdWarehouse($id_warehouse)
->select(['id_user', 'code', 'username', 'firstname', 'lastname', 'mail']); ->select('*');
return $user->fetch(); return $user->fetch();
} }

View File

@ -445,25 +445,15 @@
// var_dump($myUser); // var_dump($myUser);
$module_merge = Table::get('module_merge')
->whereIdWarehouse(7);
$selReq = Database::getPDO()->query("select m.*, max(h.timestamp) as last $chip = Table::get('chip')
from history as h, machine as m ->join('id_module', $module_merge)
where h.id_machine = m.id_machine
group by m.id_machine");
$selected = Database::delNumeric( $selReq->fetchAll() );
var_dump($selected);
$mac = Table::get('machine')
->select('*'); ->select('*');
$selected = Table::get('history') var_dump($chip->fetch());
->join('id_machine', $mac)
->select('timestamp', Rows::SEL_MAX);
var_dump($selected->fetch());
// $a = new ModuleRequest('authentificationDefault/warehouse', [ // $a = new ModuleRequest('authentificationDefault/warehouse', [