MySQL client class.
More...
Public Member Functions |
| __construct ($params) |
| Constructs a class instance.
|
| autoSelect ($fields, $tables, $where, $order=null, $limit=null) |
| Executes a select statement on the active database, and returns the result.
|
| delete ($table, $where) |
| Deletes records from the given table using the given where clause.
|
| escapeString ($string) |
| Escapes the input string for safe database insertion.
|
| executeQuery ($query) |
| Executes a query on the active database.
|
| getError () |
| Returns the error from the last MySQL function in a custom format.
|
| getFieldsName ($table) |
| Returns the name of the fields of the given table.
|
| getNumRecords ($table, $where=null, $field='id') |
| Returns the number of records in the given table selectyed by the given where clause.
|
| getTables ($like=null) |
| Returns the tables found in the connected database.
|
| getTableStructure ($table) |
| Returns information about the structure of a table.
|
| insert ($table, $data) |
| Inserts the given data in the given table.
|
| openConnection () |
| Opens the connection with the DB HOST, exits on error.
|
| queryResult ($query) |
| Returns the query result with accessible data.
|
| update ($table, $data, $where) |
| Updates the given table with the given data using the given where clause.
|
Private Member Functions |
| lastInsertedId () |
| Returns the last inserted id.
|
| setUtf8 () |
| Sets the database in order to work with utf8 chars.
|
Private Attributes |
| $_connection |
| MySQL link identifier on success connection, false on failure.
|
| $_db_charset |
| database charset
|
| $_db_dbname |
| database name
|
| $_db_host |
| database host
|
| $_db_pass |
| database password
|
| $_db_user |
| database user
|
Detailed Description
MySQL client class.
- Author:
- abidibo abidi.nosp@m.bo@g.nosp@m.mail..nosp@m.com
- Version:
- 0.99
- Date:
- 2011-2012
- Copyright:
- Otto srl MIT License
Definition at line 21 of file mysql.php.
Constructor & Destructor Documentation
Constructs a class instance.
- Parameters:
-
array | $params | the connection parameters (host, user, password, db_name, charset, connect) as key=>value |
- Returns:
- void
Implements DbManager.
Definition at line 59 of file mysql.php.
Member Function Documentation
Executes a select statement on the active database, and returns the result.
- Parameters:
-
mixed | $fields | the fields to be selected. Possible values: array of fields or string. |
mixed | $tables | the table/s from which retrieve records. Possible values: array of tables, string. |
string | $where | the where clause |
string | $order | the order by clause |
array | $limit | the limit clause |
- Returns:
- the associative array with the select statement result
Implements DbManager.
Definition at line 181 of file mysql.php.
Deletes records from the given table using the given where clause.
- Parameters:
-
string | $table | the database table |
mixed | $where | the where clause |
- Returns:
- boolean value: true on success, false on failure
Implements DbManager.
Definition at line 378 of file mysql.php.
Escapes the input string for safe database insertion.
- Parameters:
-
- Returns:
- the input string escaped
Implements DbManager.
Definition at line 79 of file mysql.php.
Executes a query on the active database.
- Parameters:
-
string | $query | the query to execute |
- Returns:
- the query result as a resource, or bool value.
Implements DbManager.
Definition at line 124 of file mysql.php.
Returns the error from the last MySQL function in a custom format.
- Returns:
- associative array containing error information
Implements DbManager.
Definition at line 160 of file mysql.php.
Returns the name of the fields of the given table.
- Parameters:
-
string | $table | the database table |
- Returns:
- array containing the name of the fields
Implements DbManager.
Definition at line 227 of file mysql.php.
Returns the number of records in the given table selectyed by the given where clause.
- Parameters:
-
string | $table | the database table |
mixed | $where | the where clause |
string | $field | the field used for counting |
- Returns:
- number of records
Implements DbManager.
Definition at line 203 of file mysql.php.
Returns the tables found in the connected database.
- Parameters:
-
string | $like | the like clause, defaut null. |
- Returns:
- array of table names
Implements DbManager.
Definition at line 298 of file mysql.php.
Returns information about the structure of a table.
- Parameters:
-
string | $table | the database table |
- Returns:
- information about the table structure.
The returned array is in the form
array("field_name" => array("property" => "value"), "primary_key" => "primary_key_name", "keys" => array("keyname1", "keyname2"))
Returned properties foreach field:
- order: the ordinal position
- deafult: the default value
- null: whether the field is nullable or not
- type: the field type (varchar, int, text, ...)
- max_length: the field max length
- n_int: the number of int digits
- n_precision: the number of decimal digits
- key: the field key if set
- extra: extra information
Implements DbManager.
Definition at line 263 of file mysql.php.
Inserts the given data in the given table.
- Parameters:
-
string | $table | the database table |
array | $data | the data to insert in the form array('field_name'=>'value') |
- Returns:
- the last inserted id on success, false on failure
Implements DbManager.
Definition at line 322 of file mysql.php.
Returns the last inserted id.
- Returns:
- the last inserted id or false
Definition at line 364 of file mysql.php.
Opens the connection with the DB HOST, exits on error.
- Returns:
- void
Implements DbManager.
Definition at line 90 of file mysql.php.
Returns the query result with accessible data.
- Parameters:
-
string | $query | the query to execute |
- Returns:
- the query result
Implements DbManager.
Definition at line 138 of file mysql.php.
Sets the database in order to work with utf8 chars.
- Returns:
- void
Definition at line 109 of file mysql.php.
Updates the given table with the given data using the given where clause.
- Parameters:
-
string | $table | |
array | $data | the data to update in the form array('field_name'=>'value') |
string | $where | the where clause |
- Returns:
- boolean value: true on success, false on failure
Implements DbManager.
Definition at line 346 of file mysql.php.
Field Documentation
MySQL link identifier on success connection, false on failure.
Definition at line 51 of file mysql.php.
database charset
Definition at line 46 of file mysql.php.
database password
Definition at line 36 of file mysql.php.
The documentation for this class was generated from the following file: