tags:

views:

42

answers:

2

If PDO's beginTransaction() fails, it returns false. What would be the best thing to do here? Here's what I'm about to do: If it returns false, I want to log something to a file.

I'm really not sure if array PDO::errorInfo ( void ) is my friend here? Would that contain more information?

A: 

As the manual says the PDO::beginTransaction() returns a bool, it basically executes the query BEGIN TRANSACTION; so the only case that I can see it can return false is if the database engine does not support transactions (e.g.: MySQL ISAM), so I don't see what kind of error information you would want to retrieve from it.

Alix Axel
Why was my answer censored?
Alix Axel
+2  A: 

You pretty much answered your own question, the only other method to obtain error information in PDO is:

PDO::errorCode

(which is already included in the errorInfo array anyway

It contains all error information available to PDO.

If for whatever reason it returns no error then I'm going to have to go with Alix Axel on this one and guess that it has something to do with transactions not being supported by the current RDBMS

Alex