RE: [PEAR] Extending DB to do minor statistics?
| From: | Lukas Smith | Date: | Sun, 03 Aug 2003 11:32:20 +0000 |
| Subject: | RE: [PEAR] Extending DB to do minor statistics? | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-6972@lists.php.net to get a copy of this message | ||
> From: Oscar Rylin [mailto:oscar@thatforum.com]
> Sent: Saturday, August 02, 2003 7:22 PM
> I was wondering how I'd go about extending DB to allow for some minor
> statistics grabbing, eg. being able to get something like
> "Page generated in x.xx MS, x% php, y% db calls (z queries)".
> Obviously, I could just increase a counter before and after every
query
> done in my code, but it would be nice to have this in DB (amount of
> queries per DB connection, how long the total amount of queries for a
DB
> connection took).
Well that would mean you would have to modify every method that runs a
query. Because of the complex inheritance structure of DB that is not
really possible through "extending" one of the classes.
If you are only concerned with queries that do "SELECT"s you could do
something sneaky by modifying the DB_Result class and looking at the
last_query property in the constructor. Atleast I think that could work.
As a little plug:
PEAR::MDB allows you to define a call back debug function to which every
query is optionally passed. This would allow you to implement what you
want quite easily (like running automatic EXPLAIN queries and stuff like
that).
Regards,
Lukas