OPiQuotations  v.02.00.00 — October 26, 2015
 All Classes Namespaces Files Functions Variables Pages
Public Member Functions | Protected Attributes | List of all members
OPiQuotations\Db Class Reference

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.

Detailed Description

Class to connect and deal to the MySQL database.

Definition at line 28 of file Db.inc.

Constructor & Destructor Documentation

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.

Parameters
string$hostHost name or IP address of the server
string$userMySQL user name
string$passwordMySQL password
string$db_nameName of the database

Definition at line 43 of file Db.inc.

References OPiQuotations\to_log().

OPiQuotations\Db::__destruct ( )

Close the connection to the database.

Definition at line 77 of file Db.inc.

Member Function Documentation

OPiQuotations\Db::escape (   $s)

Return the string with its special characters escaped for use in a SQL statement.

Parameters
string$s
Returns
string

Definition at line 107 of file Db.inc.

OPiQuotations\Db::is_connected ( )

If connection is ok then return true else return false.

Returns
bool

Definition at line 93 of file Db.inc.

OPiQuotations\Db::list_to_assoc (   $table)

Return a associative table id => array(name, number of use) of elements of the table.

Parameters
string$table(must be 'author', 'nation', 'subject' or 'work')
Returns
array[array]

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.

Parameters
null | bool$is_maxim
Returns
int >= 0

Definition at line 192 of file Db.inc.

OPiQuotations\Db::query_insert (   $query)

Execute the MySQL query INSERT.

If insertion is ok then return true, else return false.

Parameters
string$queryValid MySQL query
Returns
bool

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.

Warning
Use escape() with each string piece of $where if necessary.
Parameters
string$whereValid WHERE clause of the SELECT MySQL command used (see http://dev.mysql.com/doc/refman/5.1/en/select.html )
string$orderValid ORDER clause of the SELECT MySQL command used (see http://dev.mysql.com/doc/refman/5.1/en/select.html )
Returns
OPiQuotation[]

Definition at line 287 of file Db.inc.

Member Data Documentation

mysqli OPiQuotations\Db::$connect
protected

Connection to the MySQL database.

Definition at line 350 of file Db.inc.


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