In my new website I'm using transactions when handling my database, and then commit to make changes. It's been working fine, until now... Suddenly I noticed no changes were made, and I finally tracked the error to the part where I commit.
I have a class Database, in which all database stuff are handled, and in it's contruct I set autocommit to false, and then there's a method to commit, like this
PHP Code:
public function commit() { if (!$this->dbLink->commit()) { throw new SQLException("Could not commit"); } else { return true; } }
Evan though it wasn't working, a exception was never thrown, which means it was always returning true, right? Still, no changes were made, and I put in var_dumps and echoes here and there to check if all data being sent was correct, and it was. The SQL query being run was correct and no errors occured. Then I tried to remove the line where I set autocommit to false, and it started working! So for some reason it just didn't want to commit when I told it to. Im out of ideas...
|