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 28d493fbb8
commit 2bce5ab3bb
6 changed files with 36 additions and 48 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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