Public Member Functions | |
__construct ($host, $user, $password, $db_name) | |
Open the connection to the database $db_name. | |
__destruct () | |
Close the connection to the database. | |
is_connected () | |
If connection is ok then return true else return false. | |
escape ($s) | |
Return the string with its special characters escaped for use in a SQL statement. | |
list_to_assoc ($table) | |
Return a associative table id => array(name, number of use) of elements of the table. | |
nb ($is_maxim=null) | |
Return the numbers of quotations and/or maxims. | |
query_insert ($query) | |
Execute the MySQL query INSERT. | |
query_quotations ($where, $order='') | |
Return an array with all OPiQuotation that match with the SQL $where condition in order specified by $order. |
Protected Attributes | |
$connect | |
Connection to the MySQL database. |
OPiQuotations\Db::__construct | ( | $host, | |
$user, | |||
$password, | |||
$db_name | |||
) |
Open the connection to the database $db_name.
If connection fails then write a message in the errors log file.
See is_connected() function.
string | $host | Host name or IP address of the server |
string | $user | MySQL user name |
string | $password | MySQL password |
string | $db_name | Name of the database |
Definition at line 43 of file Db.inc.
References OPiQuotations\to_log().
OPiQuotations\Db::__destruct | ( | ) |
OPiQuotations\Db::escape | ( | $s | ) |
OPiQuotations\Db::is_connected | ( | ) |
OPiQuotations\Db::list_to_assoc | ( | $table | ) |
Return a associative table id => array(name, number of use) of elements of the table.
string | $table | (must be 'author', 'nation', 'subject' or 'work') |
Definition at line 126 of file Db.inc.
References $quots, OPiQuotations\Db\list_to_assoc(), and OPiQuotations\to_log().
Referenced by OPiQuotations\Db\list_to_assoc().
OPiQuotations\Db::nb | ( | $is_maxim = null | ) |
Return the numbers of quotations and/or maxims.
If $is_maxim === null then return the numbers of quotations/maxims,
if $is_maxim === false then return the numbers of quotations,
if $is_maxim === true then return the numbers of maxims.
null | bool | $is_maxim |
OPiQuotations\Db::query_insert | ( | $query | ) |
Execute the MySQL query INSERT.
If insertion is ok then return true, else return false.
string | $query | Valid MySQL query |
Definition at line 245 of file Db.inc.
References OPiQuotations\Db\query_insert(), and OPiQuotations\to_log().
Referenced by OPiQuotations\Db\query_insert().
OPiQuotations\Db::query_quotations | ( | $where, | |
$order = '' |
|||
) |
Return an array with all OPiQuotation that match with the SQL $where condition in order specified by $order.
string | $where | Valid WHERE clause of the SELECT MySQL command used (see http://dev.mysql.com/doc/refman/5.1/en/select.html ) |
string | $order | Valid ORDER clause of the SELECT MySQL command used (see http://dev.mysql.com/doc/refman/5.1/en/select.html ) |
|
protected |