Commit 44849044 authored by okhin's avatar okhin 🚴

AUTO_INCREMENT returns the ID of the Next attribute, not the Last one

parent fc3dabe7
Pipeline #2331 passed with stages
in 18 seconds
...@@ -440,7 +440,7 @@ class Admin extends Controller ...@@ -440,7 +440,7 @@ class Admin extends Controller
if ($user['cumul'] >= $needed) { if ($user['cumul'] >= $needed) {
// Assez de point, on crée // Assez de point, on crée
// On récupère le dernier ID inséré // On récupère le dernier ID inséré
$parent = $f3->get('container')['counterpart_finder']->getLastInsertedId() + 1; $parent = $f3->get('container')['counterpart_finder']->getNextInsertedId();
$f3->get('container')['command_handler']->handle(new CounterpartCreateCommand($adresse['id'], $user['id'], $quoi, 1, 2, date("Y-m-d H:i:s"), 'Imported from a file', $parent)); $f3->get('container')['command_handler']->handle(new CounterpartCreateCommand($adresse['id'], $user['id'], $quoi, 1, 2, date("Y-m-d H:i:s"), 'Imported from a file', $parent));
// On mets à jour le cumul de l'utilisateur // On mets à jour le cumul de l'utilisateur
$f3->get('container')['command_handler']->handle(new UserUpdateCumulCommand($user['id'], $user['cumul'] - $needed)); $f3->get('container')['command_handler']->handle(new UserUpdateCumulCommand($user['id'], $user['cumul'] - $needed));
......
...@@ -337,7 +337,7 @@ class Perso extends Controller ...@@ -337,7 +337,7 @@ class Perso extends Controller
// Ajout d'une demande de contrepartie pour chaque contrepartie // Ajout d'une demande de contrepartie pour chaque contrepartie
if ((int) $user['cumul'] >= $valeur) { if ((int) $user['cumul'] >= $valeur) {
$parent = $f3->get('container')['counterpart_finder']->getLastInsertedId() + 1; $parent = $f3->get('container')['counterpart_finder']->getNextInsertedId();
switch ($quoi) { switch ($quoi) {
case 'hoodie': case 'hoodie':
$f3->get('container')['command_handler']->handle(new CounterpartCreateCommand(\Utils::asl($adresse_id), $f3->get('SESSION.id'), 'hoodie', \Utils::asl($taille_h), 1, date("Y-m-d H:i:s"), \Utils::asl($commentaire), $parent)); $f3->get('container')['command_handler']->handle(new CounterpartCreateCommand(\Utils::asl($adresse_id), $f3->get('SESSION.id'), 'hoodie', \Utils::asl($taille_h), 1, date("Y-m-d H:i:s"), \Utils::asl($commentaire), $parent));
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
<table cellspacing="0" cellpadding="0"> <table cellspacing="0" cellpadding="0">
<theader> <theader>
<th>Id</th> <th>Id</th>
<th>Id du parent</th>
<th>Email</th> <th>Email</th>
<th>Date</th> <th>Date</th>
<th>Quoi</th> <th>Quoi</th>
...@@ -56,7 +57,8 @@ ...@@ -56,7 +57,8 @@
<repeat group="{{ @data }}" value="{{ @row }}"> <repeat group="{{ @data }}" value="{{ @row }}">
<tr> <tr>
<td>{{ @row.id }}</td> <td>{{ @row.id }}</td>
<td><a href="{{'user_info', 'id='.@row.user_id | alias }}">{{ @row.email }}</a></td> <td>{{ @row.parent }}</td>
<td><a href="{{'user_info', 'id='.@row.user_id | alias }}">{{ @row.email }}</a></td>
<td>{{ @row.datec }}</td> <td>{{ @row.datec }}</td>
<td>{{ @row.quoi }}</td> <td>{{ @row.quoi }}</td>
<td> <td>
......
...@@ -95,6 +95,7 @@ ...@@ -95,6 +95,7 @@
<table cellspacing="0" cellpadding="0"> <table cellspacing="0" cellpadding="0">
<theader> <theader>
<th>Id</th> <th>Id</th>
<th>Id du parent</th>
<th>Date</th> <th>Date</th>
<th>Quoi</th> <th>Quoi</th>
<th>Taille/Piplome</th> <th>Taille/Piplome</th>
...@@ -106,6 +107,7 @@ ...@@ -106,6 +107,7 @@
<repeat group="{{ @user.contreparties }}" value="{{ @row }}"> <repeat group="{{ @user.contreparties }}" value="{{ @row }}">
<tr> <tr>
<td>{{ @row.id }}</td> <td>{{ @row.id }}</td>
<td>{{ @row.parent }}</td>
<td>{{ @row.datec }}</td> <td>{{ @row.datec }}</td>
<td>{{ @row.quoi }}</td> <td>{{ @row.quoi }}</td>
<td> <td>
......
...@@ -58,11 +58,11 @@ EOQ; ...@@ -58,11 +58,11 @@ EOQ;
} }
/** /**
* return the last inserted id * return the id of the next item to be inserted
* *
* @return int * @return int
*/ */
public function getLastInsertedId() public function getNextInsertedId()
{ {
return (int) $this->connection->fetchColumn( return (int) $this->connection->fetchColumn(
"SELECT AUTO_INCREMENT FROM information_schema.tables WHERE table_name = 'contreparties' AND table_schema = DATABASE()" "SELECT AUTO_INCREMENT FROM information_schema.tables WHERE table_name = 'contreparties' AND table_schema = DATABASE()"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment