Phpfox_Database_Driver_Mysql

Description

Database driver for MySQL.

  • author: Raymond Benc
  • version: $Id: mysql.class.php 1687 2010-07-22 03:13:27Z Raymond_Benc $
  • copyright: [PHPFOX_COPYRIGHT]

Located in /include/library/phpfox/database/driver/mysql.class.php (line 16)

Phpfox_Database_Dba
   |
   --Phpfox_Database_Driver_Mysql
Direct descendents
Class Description
 class Phpfox_Database_Driver_Mysqli Database driver for MySQLi. This class extends the MySQL driver we provide since both function in the same way there was no need to make an extra class for MySQLi.
Variable Summary
 unknown_type $sSlaveServer
 array $_aCmd
 bool $_bIsSlave
 resource $_hMaster
 resource $_hSlave
Method Summary
 resource addField (array $aParams)
 resource addIndex (string $sTable, string $sField)
 array affectedRows ()
 string backup (string $sPath)
 bool canBackup ()
 bool connect (string $sHost, string $sUser, string $sPass, string $sName, [mixed $sPort = false], [bool $sPersistent = false])
 resource dropField (string $sTable, string $sField)
 mixed escape (mixed $mParam)
 void freeResult ()
 int getLastId ()
 string getServerInfo ()
 array getTableStatus ()
 string getVersion ()
 bool isField (string $sTable, string $sField)
 string isNotNull (string $sField)
 string isNull (string $sField)
 resource optimizeTable (string $sTable)
 resource query (string $sSql, [ &$hLink = ''], resource $hLink)
 resource repairTable (string $sTable)
 string search (string $sType, mixed $mFields, string $sSearch)
 string sqlReport (string $sQuery)
 bool tableExists (string $sTable)
 bool _connect (string $sHost, string $sUser, string $sPass, [mixed $sPort = false], [bool $sPersistent = false], string $sName)
 array _getRow (string $sSql, string $bAssoc,  &$hLink)
 array _getRows (string $sSql, [string $bAssoc = true],  &$hLink)
 string _sqlError ()
Variables
unknown_type $sSlaveServer (line 23)

IP/Host of the slave server we are currently using.

  • access: public
array $_aCmd = array(
'mysql_query' => 'mysql_query',
'mysql_connect' => 'mysql_connect',
'mysql_pconnect' => 'mysql_pconnect',
'mysql_select_db' => 'mysql_select_db',
'mysql_num_rows' => 'mysql_num_rows',
'mysql_fetch_array' => 'mysql_fetch_array',
'mysql_real_escape_string' => 'mysql_real_escape_string',
'mysql_insert_id' => 'mysql_insert_id',
'mysql_fetch_assoc' => 'mysql_fetch_assoc',
'mysql_free_result' => 'mysql_free_result',
'mysql_error' => 'mysql_error',
'mysql_affected_rows' => 'mysql_affected_rows',
'mysql_get_server_info' => 'mysql_get_server_info'
)
(line 53)

Holds an array of all the MySQL functions we use. We store it here because we also provide support for MySQLi, which extends this class when it use.

  • access: protected

Redefined in descendants as:
bool $_bIsSlave = false (line 44)

Check to see if we are using slave servers

  • access: protected
resource $_hMaster = null (line 30)

Resource for the MySQL master server

  • access: protected
resource $_hSlave = null (line 37)

Resource for the MySQL salve server

  • access: protected

Inherited Variables

Inherited from Phpfox_Database_Dba

Phpfox_Database_Dba::$_aData
Phpfox_Database_Dba::$_aQuery
Phpfox_Database_Dba::$_aWords
Methods
addField (line 363)

Adds fields to a database table.

  • return: Returns the MySQL resource from mysql_query()
  • access: public
resource addField (array $aParams)
  • array $aParams: Array of fields and what type each field is.
addIndex (line 350)

Adds an index to a table.

  • return: Returns the MySQL resource from mysql_query()
  • access: public
resource addIndex (string $sTable, string $sField)
  • string $sTable: Database table.
  • string $sField: List of indexes to add.
affectedRows (line 246)

Returns the affected rows.

  • access: public
array affectedRows ()
backup (line 486)

Performs a backup of the database and places the backup in a specific area on the server based on what the admins decide.

  • return: Full path to where the backup is located including the file name.
  • access: public
string backup (string $sPath)
  • string $sPath: Full path to where to place the backup.
canBackup (line 474)

Checks if we can backup the database or not. This depends on the server itself.

We currently only support unix based servers.

  • return: Returns true if we can backup or false if we can't
  • access: public
bool canBackup ()
connect (line 80)

Makes a connection to the MySQL database

  • return: If we were able to connect we return true, however if it failed we return false and a error message why.
  • access: public
bool connect (string $sHost, string $sUser, string $sPass, string $sName, [mixed $sPort = false], [bool $sPersistent = false])
  • string $sHost: Hostname or IP
  • string $sUser: User used to log into MySQL server
  • string $sPass: Password used to log into MySQL server. This can be blank.
  • string $sName: Name of the database.
  • mixed $sPort: Port number (int) or false by default since we do not need to define a port.
  • bool $sPersistent: False by default but if you need a persistent connection set this to true.
dropField (line 389)

Drops a specific field from a table.

  • return: Returns the MySQL resource from mysql_query()
  • access: public
resource dropField (string $sTable, string $sField)
  • string $sTable: Database table
  • string $sField: Name of the field to drop
escape (line 202)

Prepares string to store in db (performs addslashes() )

  • return: escaped string or array of escaped strings
  • access: public
mixed escape (mixed $mParam)
  • mixed $mParam: string or array of string need to be escaped
freeResult (line 233)

Frees the MySQL results

  • access: public
void freeResult ()
getLastId (line 224)

Returns row id from last executed query

  • return: id of last INSERT operation
  • access: public
int getLastId ()
getServerInfo (line 153)

Returns MySQL server information. Here we only identify that it is MySQL and the version being used.

  • access: public
string getServerInfo ()
getTableStatus (line 420)

Returns the status of the table.

  • return: Returns information about the table in an array.
  • access: public
array getTableStatus ()
getVersion (line 143)

Returns the MySQL version

  • access: public
string getVersion ()
isField (line 401)

Checks if a field already exists or not.

  • return: If the field exists we return true, if not we return false.
  • access: public
bool isField (string $sTable, string $sField)
  • string $sTable: Database table to check
  • string $sField: Name of the field to check
isNotNull (line 338)

Check if a field in the database is set not null

  • return: Returns MySQL IS NOT NULL usage
  • access: public
string isNotNull (string $sField)
  • string $sField: The field we plan to check
isNull (line 327)

Check if a field in the database is set to null

  • return: Returns MySQL IS NULL usage
  • access: public
string isNull (string $sField)
  • string $sField: The field we plan to check
optimizeTable (line 452)

Optimizes a table

  • return: Returns the MySQL resource from mysql_query()
  • access: public
resource optimizeTable (string $sTable)
  • string $sTable: Table to optimize
query (line 166)

Performs sql query with error reporting and logging.

  • return: Returns the MYSQL resource from the function mysql_query()
  • see: mysql_query()
  • access: public
resource query (string $sSql, [ &$hLink = ''], resource $hLink)
  • string $sSql: MySQL query to perform
  • resource $hLink: MySQL resource. If nothing is passed we load the default master server.
  • &$hLink
repairTable (line 463)

Repairs a table

  • return: Returns the MySQL resource from mysql_query()
  • access: public
resource repairTable (string $sTable)
  • string $sTable: Table to repair
search (line 259)

MySQL has special search functions, so we try to use that here.

  • return: MySQL query to use when performing the search
  • access: public
string search (string $sType, mixed $mFields, string $sSearch)
  • string $sType: Type of search we plan on doing.
  • mixed $mFields: Array of fields to search
  • string $sSearch: Value to search for.
sqlReport (line 284)

During development you may need to check how your queries are being executed and how long they are taking. This routine uses MySQL's EXPLAIN to return useful information.

  • return: HTML output of the information we have found about the query.
  • access: public
string sqlReport (string $sQuery)
  • string $sQuery: MySQL query to check.
tableExists (line 431)

Checks if a database table exists.

  • return: If the table exists we return true, if not we return false.
  • access: public
bool tableExists (string $sTable)
  • string $sTable: Table we are looking for.
_connect (line 566)

Makes a connection to the MySQL database

  • return: If we were able to connect we return true, however if it failed we return false and a error message why.
  • access: private
bool _connect (string $sHost, string $sUser, string $sPass, [mixed $sPort = false], [bool $sPersistent = false], string $sName)
  • string $sHost: Hostname or IP
  • string $sUser: User used to log into MySQL server
  • string $sPass: Password used to log into MySQL server. This can be blank.
  • string $sName: Name of the database.
  • mixed $sPort: Port number (int) or false by default since we do not need to define a port.
  • bool $sPersistent: False by default but if you need a persistent connection set this to true.
_getRow (line 519)

Returns exactly one row as array. If there is number of rows satisfying the condition then the first one will be returned.

  • return: exact one row (first if multiply row selected): or false on error
  • access: protected
array _getRow (string $sSql, string $bAssoc,  &$hLink)
  • string $sSql: select query
  • string $bAssoc: type of returned rows array
  • &$hLink
_getRows (line 537)

Gets data returned by sql query

  • return: selected rows (each row is array of specified type) or emprt array on error
  • access: protected
array _getRows (string $sSql, [string $bAssoc = true],  &$hLink)
  • string $sSql: select query
  • string $bAssoc: type of returned rows array
  • &$hLink
_sqlError (line 586)

Returns any SQL errors.

  • return: String of error message in case something failed.
  • access: private
string _sqlError ()

Inherited Methods

Inherited From Phpfox_Database_Dba

 Phpfox_Database_Dba::__construct()
 Phpfox_Database_Dba::clean()
 Phpfox_Database_Dba::delete()
 Phpfox_Database_Dba::dropTables()
 Phpfox_Database_Dba::execute()
 Phpfox_Database_Dba::from()
 Phpfox_Database_Dba::getField()
 Phpfox_Database_Dba::getRow()
 Phpfox_Database_Dba::getRows()
 Phpfox_Database_Dba::getSlaveField()
 Phpfox_Database_Dba::getSlaveRow()
 Phpfox_Database_Dba::getSlaveRows()
 Phpfox_Database_Dba::group()
 Phpfox_Database_Dba::having()
 Phpfox_Database_Dba::innerJoin()
 Phpfox_Database_Dba::insert()
 Phpfox_Database_Dba::join()
 Phpfox_Database_Dba::leftJoin()
 Phpfox_Database_Dba::limit()
 Phpfox_Database_Dba::multiInsert()
 Phpfox_Database_Dba::order()
 Phpfox_Database_Dba::process()
 Phpfox_Database_Dba::select()
 Phpfox_Database_Dba::update()
 Phpfox_Database_Dba::updateCount()
 Phpfox_Database_Dba::updateCounter()
 Phpfox_Database_Dba::where()
 Phpfox_Database_Dba::_getField()
 Phpfox_Database_Dba::_insert()
 Phpfox_Database_Dba::_join()
 Phpfox_Database_Dba::_update()

Documentation generated on Tue, 28 Sep 2010 10:36:42 +0200 by phpDocumentor 1.4.0a2