Here's a strange case that has never happened to me before, I've been coding with mysqli and php for about 2 years now, very basic stuff, prepared statements, query executes, etc, started with WAMP, then moved to ubuntu, tried LAMP, didn't like it, went on investigating a proper testing enviroment, and I found PuPHPet, which was perfect, have been working with it a few months, and everything is going great.
Never in all this time I had to worry about opening, closing or commiting connections, like I do in JAVA, I read somewhere that php handles connections, it opens and closes them when the scripts runs. I've never really pay much attention, which I should have, I found this very useful post PHP + MySQL transactions examples, which I will start using from now on.
But the reason I'm posting here, is because all of a sudden autocommit is off. I opened my usual puphpet project, tried inserting some new entries, and they did not get inserted. So, I made some test in workbench, inserted some entries manually, they got inserted, but my AI index had incremented, meaning that my app did insert something, or at least it tried, or something happened because the AI counter had increased. Got some help from a couple of DBA and we got to the conclusion that it is the autocommit.
Using this piece of code:
$res = mysqli_query($mysqli, "SELECT @@autocommit");
$row = mysqli_fetch_row($row);
printf("Autocommit: %s\n", $row[0]);
It prints "Autocommit: 0", so it is off, but I didn't change anything, even in production enviroment autocommit is on, or at least my inserts stay there, but I don't know why it changed in my test enviroment, so I'm wondering what could have happened? Anybody got any ideas?