server-php-micro-db-manager-DBManager.class.php / php
<?php
This is a MySQL handler class
version: 1.0
author: PhpToys @copyright PhpToys 2007
class DBManager{ var queryCounter = 0; var errorCode = 0; var resultSet = '';
Constuctor of the class. Connects to the server and selects the database.
parameter: string
parameter: string user
parameter: string
parameter: string db
returns: DBManager
function DBManager(user, db){ this->getMicroTime(); // Try to make a connection to the server if (!host,pass,true)){ this->errorMsg = mysql_error(); return false; } // Now select the database if (!@mysql_select_db(this->connection)){ this->errorMsg = mysql_error(); @mysql_close(this->totalTime += startTime; return true; }
Execute the sql statement and returns with the result set.
parameter: string
returns: unknown
function executeQuery(sql){ this->getMicroTime(); ++this->resultSet = @mysql_query(this->connection)){ this->errorMsg = mysql_error(); this->getMicroTime() - this->totalTime += startTime; return
This function loads the previous query result into an array.
returns: array
function loadResult() { array = array(); while (this->resultSet )) { row; } mysql_free_result( array; }
Returns with the number of selected rows in the previous sql statement.
returns: int
function getSelectedRows() { return @mysql_num_rows(
Returns with the number of the affected rows in the previous sql statement.
returns: int
function getAffectedRows() { return @mysql_affected_rows(this->connection); }
Get the ID generated from the previous INSERT operation
returns: int
function getInsertId(){ return @mysql_insert_id(
Return the total time spended in this class
returns: float
function getDBTime(){ return round(this->totalTime,6); } function getSqlCount(){ return this->errorCode; } function getErrorMessage(){ return usec, usec + (float)
(C) Æliens 20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.