Open ajanini opened 9 years ago
use $this -> setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
a good practice to turn off the production output of the error
for example, you can use this component https://github.com/vlucas/phpdotenv
Hi @visavi, thanks for your help.
Could you give me some more info? For instance: I am calling a static method ::all()
. I can't use $this
in that context.
Also, I am trying to suppress the error. Shouldn't the option be PDO::ERRMODE_SILENT
?
Invoking setAttribute
is different than setting this option directly in Connection.php
file? I've tried that with no luck.
Like I said, I've tried to turn off error reporting in PHP, but that error continues to be printed.
I think everything is clearly stated, I do not even know how to reassign https://github.com/jpfuentes2/php-activerecord/blob/b2ed6fc64ef35c88fd30d71091df0d0765719901/lib/Connection.php#L64
I'm afraid I don't understand.
Like I said in my first post, I tried changing https://github.com/jpfuentes2/php-activerecord/blob/b2ed6fc64ef35c88fd30d71091df0d0765719901/lib/Connection.php#L66 to PDO::ERRMODE_SILENT
.
This did not fix the problem.
When the PDO connection to the database fails, a
PDOException
is thrown that shows the password in plaintext (you can test this by typing an incorrect username or password).I've tried setting
PDO::ATTR_ERRMODE
toPDO::ERRMODE_SILENT
inConnection.php
file, and that doesn't seem to help.I've also tried to turn off PHP error reporting, but I can't seem to prevent the exception trace info printed to the browser.
Implementing
try
/catch
blocks in every query seems very unpractical.Have I overlooked something? How should I deal with this problem?