Jeff PHP framework  0.99
Modular, extensible, OOP, MVC, lightweight php framework designed to ease the programmers in the development of web applications.
mysql Class Reference

MySQL client class. More...

+ Inheritance diagram for mysql:
+ Collaboration diagram for mysql:

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

Definition at line 21 of file mysql.php.


Constructor & Destructor Documentation

mysql::__construct ( params)

Constructs a class instance.

Parameters:
array$paramsthe connection parameters (host, user, password, db_name, charset, connect) as key=>value
Returns:
void

Implements DbManager.

Definition at line 59 of file mysql.php.

+ Here is the call graph for this function:


Member Function Documentation

mysql::autoSelect ( fields,
tables,
where,
order = null,
limit = null 
)

Executes a select statement on the active database, and returns the result.

Parameters:
mixed$fieldsthe fields to be selected. Possible values: array of fields or string.
mixed$tablesthe table/s from which retrieve records. Possible values: array of tables, string.
string$wherethe where clause
string$orderthe order by clause
array$limitthe limit clause
Returns:
the associative array with the select statement result

Implements DbManager.

Definition at line 181 of file mysql.php.

+ Here is the call graph for this function:

mysql::delete ( table,
where 
)

Deletes records from the given table using the given where clause.

Parameters:
string$tablethe database table
mixed$wherethe where clause
Returns:
boolean value: true on success, false on failure

Implements DbManager.

Definition at line 378 of file mysql.php.

+ Here is the call graph for this function:

mysql::escapeString ( string)

Escapes the input string for safe database insertion.

Parameters:
string$string
Returns:
the input string escaped

Implements DbManager.

Definition at line 79 of file mysql.php.

mysql::executeQuery ( query)

Executes a query on the active database.

Parameters:
string$querythe query to execute
Returns:
the query result as a resource, or bool value.

Implements DbManager.

Definition at line 124 of file mysql.php.

+ Here is the caller graph for this function:

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.

mysql::getFieldsName ( table)

Returns the name of the fields of the given table.

Parameters:
string$tablethe database table
Returns:
array containing the name of the fields

Implements DbManager.

Definition at line 227 of file mysql.php.

+ Here is the call graph for this function:

mysql::getNumRecords ( table,
where = null,
field = 'id' 
)

Returns the number of records in the given table selectyed by the given where clause.

Parameters:
string$tablethe database table
mixed$wherethe where clause
string$fieldthe field used for counting
Returns:
number of records

Implements DbManager.

Definition at line 203 of file mysql.php.

+ Here is the call graph for this function:

mysql::getTables ( like = null)

Returns the tables found in the connected database.

Parameters:
string$likethe like clause, defaut null.
Returns:
array of table names

Implements DbManager.

Definition at line 298 of file mysql.php.

+ Here is the call graph for this function:

Returns information about the structure of a table.

Parameters:
string$tablethe 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.

+ Here is the call graph for this function:

mysql::insert ( table,
data 
)

Inserts the given data in the given table.

Parameters:
string$tablethe database table
array$datathe 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.

+ Here is the call graph for this function:

mysql::lastInsertedId ( ) [private]

Returns the last inserted id.

Returns:
the last inserted id or false

Definition at line 364 of file mysql.php.

+ Here is the caller graph for this function:

Opens the connection with the DB HOST, exits on error.

Returns:
void

Implements DbManager.

Definition at line 90 of file mysql.php.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

mysql::queryResult ( query)

Returns the query result with accessible data.

Parameters:
string$querythe query to execute
Returns:
the query result

Implements DbManager.

Definition at line 138 of file mysql.php.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

mysql::setUtf8 ( ) [private]

Sets the database in order to work with utf8 chars.

Returns:
void

Definition at line 109 of file mysql.php.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

mysql::update ( table,
data,
where 
)

Updates the given table with the given data using the given where clause.

Parameters:
string$table
array$datathe data to update in the form array('field_name'=>'value')
string$wherethe where clause
Returns:
boolean value: true on success, false on failure

Implements DbManager.

Definition at line 346 of file mysql.php.

+ Here is the call graph for this function:


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.

mysql::$_db_dbname [private]

database name

Definition at line 41 of file mysql.php.

mysql::$_db_host [private]

database host

Definition at line 26 of file mysql.php.

mysql::$_db_pass [private]

database password

Definition at line 36 of file mysql.php.

mysql::$_db_user [private]

database user

Definition at line 31 of file mysql.php.


The documentation for this class was generated from the following file: