Skip beginTransaction commit PDO MYSQL

0

What happens in practice when I omit begin transaction and commit in a PHP script using PDO?

I have a load script, which processes the school data, with each school that finishes processing I make a insert . This code below is in a loop that runs through a gigantic list of schools. In this case I did not insert begintran and commit . Does he eat self after each insertion?

$insere = $pdo->prepare("Insert INTO 'tabela'(campo1,campo2,campo3) VALUES (:valor1,:valor2,:valor3)");
        $insere->bindValue(":valor1", $dado1);
        $insere->bindValue(":valor2", $dado2);
        $insere->bindValue(":valor3", $dado3);
        $insere->execute();
    
asked by anonymous 31.03.2016 / 05:32

1 answer

0

Yes

In the case of a database that follows the ACID model, in the absence of transactions, then each statement ends up having an automatic implicit transaction. Basically it is autocommit for each statement. And MySQL follows this template .

In this particular case be prepared to deal with glitches. If you make a mistake in processing this "gigantic" list, then a new round of the script may not work (INSERTs fail for primary key duplication).

    
31.03.2016 / 07:17