Class DBWrapper

Description

MySQL database wrapper class

This class is a simple object-oriented wrapper of PHP's MySQL functions.



			
Variable Summary
Method Summary
int affectedRows ()
resource connect (string $server, string $username, string $password, string $database, [bool $persistency = false])
bool disconnect ()
string escape (string $str)
mixed fetchResult (int $row, mixed $field)
mixed fetchRow ([int $fetchType = DBW_FETCH_ASSOC])
mixed fetchRows ([int $fetchType = DBW_FETCH_ASSOC])
string fieldName (string $index)
string fieldType (string $index)
bool freeResult ()
array getError ()
int insertID ()
int numFields ()
int numRows ()
bool query (string $sql)
bool seekRow (int $row)
Variables
int $debugMode = DBW_NO_DEBUG (line 75)

Debugging mode

DBW_NO_DEBUG - not in debugging mode (default); DBW_WARNINGS - generate debug warnings; DBW_ERRORS - generate debug errors.

  • access: public
int $numQueries = 0 (line 63)

Total number of executed queries

  • access: public
Methods
affectedRows (line 182)

Get number of affected rows in previous operation

  • return: Number of affected rows, -1 if the last query failed or false if the function failed.
  • access: public
int affectedRows ()
connect (line 105)

Connect the database server and select a database on it

  • return: A Valid connection ID or false.
  • access: public
resource connect (string $server, string $username, string $password, string $database, [bool $persistency = false])
  • string $server: Database hostname.
  • string $username: Database connection username.
  • string $password: Database connection password.
  • string $database: Database name.
  • bool $persistency: Create a persistant connection?
disconnect (line 132)

Close database connection

  • access: public
bool disconnect ()
escape (line 150)

Escape unescaped string to use in SQL statement

  • return: Escaped string.
  • access: public
string escape (string $str)
  • string $str: Unescaped string.
fetchResult (line 316)

Get result data

  • return: Result data or Enumerated array of fetched row arrays or objects.
  • access: public
mixed fetchResult (int $row, mixed $field)
  • int $row: Row index.
  • mixed $field: Field name or index.
fetchRow (line 274)

Fetch a result row

  • return: Fetched array or object.
  • access: public
mixed fetchRow ([int $fetchType = DBW_FETCH_ASSOC])
  • int $fetchType: DBW_FETCH_ASSOC - fetch an associative array, DBW_FETCH_ORDERED - fetch an enumerated array, DBW_FETCH_OBJECT - fetch object.
fetchRows (line 297)

Fetch a set of result rows

  • return: Enumerated array of fetched row arrays or objects
  • access: public
mixed fetchRows ([int $fetchType = DBW_FETCH_ASSOC])
  • int $fetchType: DBW_FETCH_ASSOC - fetch rows as associative arrays, DBW_FETCH_ORDERED - fetch rows as enumerated arrays, DBW_FETCH_OBJECT - fetch rows as objects
fieldName (line 235)

Get the name of the specified field in a result

  • return: Name of the specified field or false if the function failed.
  • access: public
string fieldName (string $index)
  • string $index: Field_index starts at 0.
fieldType (line 254)

Get the type of the specified field in a result

  • return: Type of the specified field or false if the function failed.
  • access: public
string fieldType (string $index)
  • string $index: Field_index starts at 0.
freeResult (line 360)

Free result memory

  • return: False if the function failed.
  • access: public
bool freeResult ()
getError (line 376)

Returns the text and code of the error message from previous operation

  • return: [0]=>string $errorMsg, [1]=>int $errorCode.
  • access: public
array getError ()
insertID (line 348)

Get the ID generated from the previous INSERT operation

  • return: 0 if the previous query does not generate an AUTO_INCREMENT value.
  • access: public
int insertID ()
numFields (line 216)

Get number of fields in result

  • return: Number of fields in result or false if the function failed.
  • access: public
int numFields ()
numRows (line 199)

Get number of rows in result

  • return: Number of rows in result or false if the function failed.
  • access: public
int numRows ()
query (line 163)

Execute SQL statement

  • access: public
bool query (string $sql)
  • string $sql: SQL statement.
seekRow (line 332)

Move internal result pointer

  • return: False if failed to move the pointer.
  • access: public
bool seekRow (int $row)
  • int $row: Row_number starts at 0.

Documentation generated by phpDocumentor