separate logs for pdo

using pdo, is there a way to have a log of errors and a log of dbquery and a log of dbfetch
LVL 1
rgb192Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
Do you mean automatically?

Not  that I am aware of - read this to see what the issues are

http://stackoverflow.com/questions/2411182/how-to-debug-pdo-database-queries
0
Ray PaseurCommented:
Yes, of course!  This would be true of PDO, MySQLi or any other data base API.  You can extend any of the data base classes to add your own query() method.  The extension would be the correct place to use error logging.  

Most of the PHP code I've seen does not even test for errors.  The error indicators are set in the environment, but it is up to the client script to decide whether and how to use the indicators.  While this sounds confusing (why set an error indicator but not log it?) it actually makes a lot of sense once you get to understand a bit about application development.  

Let's say we had a built-in error handler that raised warnings and wrote error logs whenever, for example, MySQL encountered an error.  MySQL raises error number 1054 for an attempt to insert a duplicate value into a UNIQUE column.  Is this really an error that needs to be logged?  Probably not -- the app developer may have relied on the UNIQUE constraint to avoid duplicates, and the attempt does not represent an error in the application design (think UNIQUE user-ids, for example).  The attempt would be something that the application would detect and handle, not something that the data base extension should flag as a failure.

If your script extended the query() method to add error handling, the #1054 error would be handled differently from the other MySQL errors, so it would be your privilege and responsibility to write clear rules for what should be logged or reported.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rgb192Author Commented:
Now i can look into pdo logging with these examples

thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.