on('postEdit', function( $editor, $json, $data ) Lock wait timeout exceeded; try restarting transact

on('postEdit', function( $editor, $json, $data ) Lock wait timeout exceeded; try restarting transact

commediacommedia Posts: 21Questions: 5Answers: 0

Hi!
I need to use postEdit function to update another table of my DB as follow:

$data->on('postEdit', function( $editor, $json, $data ) {
  global $conn;
  $ordinato = getOrdinato($data['fromNav_Disponibilita']['idArticolo']);
  if ($ordinato) {
    $idArticoloFisso = $ordinato['idArticoloFisso'];
     $sqlUpdate = "UPDATE righe_disponibilita
      SET idArticolo = '".$idArticoloFisso."' 
      WHERE idArticoloFisso = '".$idArticoloFisso."'";
    if ( $resUpdate = $conn->query($sqlUpdate) ) {
        // tutto ok
        //echo $resUpdate;
      } else {
        echo $conn->error;
        }
  }          
});

I get this error : Lock wait timeout exceeded; try restarting transaction

I don't know why. I do the same update for create as follow

if ( isset($_POST['action']) && $_POST['action'] === 'create' ) {
    $ordinato = getOrdinato($_POST['data'][0]['fromNav_Disponibilita']['idArticolo']);
  if ($ordinato) {
    $idArticoloFisso = $ordinato['idArticoloFisso'];
    $sqlUpdate = "UPDATE righe_disponibilita
      SET idArticolo = '".$idArticoloFisso."' 
      WHERE idArticoloFisso = '".$idArticoloFisso."'";
    if ( $resUpdate = $conn->query($sqlUpdate) ) {
        // tutto ok
        //echo $resUpdate;
      } else {
        echo $conn->error;
        }
  }
}

and all goes well.
Thank you
Pat

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,692Questions: 1Answers: 10,500 Site admin
    Answer ✓

    Could you try adding ->transaction( false ) immediately prior to where you call the ->process() method please?

    Thanks,
    Allan

  • commediacommedia Posts: 21Questions: 5Answers: 0

    Hi Allan!
    YES all is ok! Thank you very much!

    Pat

This discussion has been closed.