0

I'm trying to retrieve last updated ids from a request, it doesn't work and I don't know why, here is my code :

$iphones=$pdo->query("SELECT * FROM categoryIphone");
$iphones=$iphones->fetchAll();

foreach ($velos as $key => $value) {
if(isset($_SESSION['commande'][$value['categoryIphoneName']])){
    $quantite=$_SESSION['commande'][$value['categoryIphoneName']];
    $idCategoryIphone=$value['categoryIponeId'];
    $updateCategoryIphone=$pdo->query("
        SET @uids := null;
        UPDATE iphone 
        SET iphoneStatut='taken', fkIphone_clientId=$idInsereDuClient, fkIphone_commandeId=$idInsereCommande 
        WHERE IphoneStatut='available' && fkIphone_categoryIphoneId=$idCategoryIphone && fkIphone_partenaireId=$fkCommande_partenaireId &&(SELECT @uids := CONCAT_WS(',', iphoneId, @uids))
        LIMIT $quantite");

   }
}

$idInsereDuClient and $idIinsereCommande come from two previous queries.

JohnDickinson
  • 97
  • 1
  • 3
  • 11
  • you forgot to ask a question/describe a problem – Jeff Jun 03 '18 at 22:30
  • Possible duplicate of [How to get ID of the last updated row in MySQL?](https://stackoverflow.com/questions/1388025/how-to-get-id-of-the-last-updated-row-in-mysql) – Jeff Jun 03 '18 at 22:32
  • I just edited my code ; the problem is that I don't know how to retrieve the last updated IDs, I tried something but it doesn't work. – JohnDickinson Jun 03 '18 at 22:32
  • I come from that topic and it's because the code doesn't work that I created a new one. – JohnDickinson Jun 03 '18 at 22:36
  • your query is quite different than the answer in the linked question. Missing the `Select @uids` at the end as second statement. – Jeff Jun 03 '18 at 22:48
  • That's because I don't understand the correct syntax. When I try it, I have this message : Cannot execute queries while other unbuffered queries are active – JohnDickinson Jun 03 '18 at 22:56
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/172397/discussion-between-johndickinson-and-jeff). – JohnDickinson Jun 04 '18 at 10:42

0 Answers0