Naez Posted March 27, 2008 Share Posted March 27, 2008 How can I keep track of how many queries are executed when using PDO? For like a footer of a website (i.e., 7 Queries) Link to comment https://forums.phpfreaks.com/topic/98108-pdo-question/ Share on other sites More sharing options...
Naez Posted March 27, 2008 Author Share Posted March 27, 2008 *bump* Link to comment https://forums.phpfreaks.com/topic/98108-pdo-question/#findComment-502205 Share on other sites More sharing options...
Naez Posted March 27, 2008 Author Share Posted March 27, 2008 Had to bump again, post floated down to page 3 :-\ Nobody knows? ??? Link to comment https://forums.phpfreaks.com/topic/98108-pdo-question/#findComment-502497 Share on other sites More sharing options...
BlueSkyIS Posted March 27, 2008 Share Posted March 27, 2008 sorry, no. i had to search for php pdo to even know what it is. Link to comment https://forums.phpfreaks.com/topic/98108-pdo-question/#findComment-502498 Share on other sites More sharing options...
Naez Posted March 27, 2008 Author Share Posted March 27, 2008 PDO is a built-in database abstraction class and it looks by the way things are heading it will be the standard for everything database related soon enough. Link to comment https://forums.phpfreaks.com/topic/98108-pdo-question/#findComment-502509 Share on other sites More sharing options...
discomatt Posted March 27, 2008 Share Posted March 27, 2008 You have to make a custom class. Every time a class member (function) is called that executes a PDO query, increment a public variable by 1. At end of page, echo that variable. Link to comment https://forums.phpfreaks.com/topic/98108-pdo-question/#findComment-502520 Share on other sites More sharing options...
Naez Posted March 27, 2008 Author Share Posted March 27, 2008 is there a good way to do this with extending PDO or just go with a custom class to accomplish? Link to comment https://forums.phpfreaks.com/topic/98108-pdo-question/#findComment-502538 Share on other sites More sharing options...
discomatt Posted March 27, 2008 Share Posted March 27, 2008 I'm not sure what you mean when you say extending PDO... Personally, i'd just do something like this (it's all in mysql, just convert over to PDO) <?php class classSql { private $link; public $error, $count = 0; public function __construct($s = FALSE, $u = FALSE, $p = FALSE, $db = FALSE) { if ($s == FALSE || $u == FALSE || $p == FALSE || $db == FALSE) // Assumes db connection is already made $this->link = FALSE; else { $this->link = mysql_connect($s, $u, $p); mysql_select_db($db, $this->link); // Add error checking obivously, this is just an example } } public function select ($table, $columns, $misc = FALSE) { foreach ($columns as $column) { // Convert array to `colname`, `colname2`.. ect } mysql_query($builtString, $this->link); // add error checking, if there's no error, increment count $this->count++; } // add more functions for INSERT, UPDATE, DELETE ect... } ?> then at the end of the script, $this->count will hold the total queries executed. This is just a quick sample, don't use anything i've posted above in an actual script please Link to comment https://forums.phpfreaks.com/topic/98108-pdo-question/#findComment-502577 Share on other sites More sharing options...
BrandonK Posted March 27, 2008 Share Posted March 27, 2008 Check out Zend_Db_Profiler from the Zend Framework. Its really cool and might give you a good idea or two Link to comment https://forums.phpfreaks.com/topic/98108-pdo-question/#findComment-502580 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.