[RESOLVED] PDO Creates a file?

liunx

Guest
I found a file called;

"host=xxxxx;dbname=xxxx"

It appears to be empty. but what is this file? it seems to be made on the initialisation of a PDO object.

What is it for?Ok, it seems the PDO object creates a empty file with that name if you give it an incorrect driver name. However, I don't understand why I'm not getting any errors.

Strange, but nevermind.It's all OO 'round here these days :) PDO throws a PDOException if the driver is duff. I don't see any spurious files being created; is it something you do if/when you catch the exception?How bizarre, I cant get it to do it again.

I changed the everything back to what it was and now its just throwing an error. I guess you must be right and I had a strange problem when I was catching (or maybe not catching) the exception.

I was catching Exception, rather than PDOException - does this make much difference? I guess I should read about it and use it instead.

Either that or I'm raving mad and/or tripping out. :eek:I was catching Exception, rather than PDOException - does this make much difference?No, not really; PDOException is a subclass of Exception, so catching the latter will catch the former. Subclassing exceptions lets you filter out which exceptions you intend to catch and handle, and which you'll leave to be caught higher up the chain; generally you'd catch the most specific exception relevant to your needs.

(If you're writing your own exception classes you can customise them with additional methods and properties the same as for any other class. A PDOException, for example, comes with an additional $errorInfo field.)
 
Back
Top