Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- How to modify a mysql_pconnect function in order to count queries
- $hostname = "localhost";
- $database = "listings";
- $username = "joe";
- $password = "1234";
- $my_connection = mysql_pconnect($hostname, $username, $password) or trigger_error(mysql_error(),E_USER_ERROR);
- class MySQLWrapper
- {
- private $_link;
- private $_totalQueries;
- /**
- * Connects to the database server
- *
- * @param string $hostname
- * @param string $username
- * @param string $password
- *
- */
- public function connect($hostname, $username, $password) {
- if (is_null($this->_link)) {
- $this->_link = mysql_pconnect($hostname, $username, $password);
- }
- }
- /**
- * Performs query
- *
- * @param string $sql
- * @return resource
- */
- public function query($sql) {
- $this->_totalQueries++;
- return mysql_query($sql, $this->_link);
- }
- /**
- * Returns count of queries made
- * @return int
- */
- public function getTotalQueryCount() {
- return $this->_totalQueries;
- }
- }
Add Comment
Please, Sign In to add comment