This class contains functions for database interaction based on MySQLi in CONTENIDO.

Configurable via global $cfg['db']['connection'] configuration as follows:

- host      (string)  Hostname or ip
- database  (string)  Database name
- user      (string)  User name
- password  (string)  User password
- options   (array)   Optional, MySQLi options array
- socket    (int)     Optional, socket
- port      (int)     Optional, port
- flags     (int)     Optional, flags
- charset  (string)   Optional, connection charset
see http://www.php.net/manual/en/mysqli.real-connect.php
package Core
subpackage Database

 Methods

Constructor of the database driver.

__construct(array $dbCfg) : \cDbDriverAbstract
Inherited

Currently stores the given configuration locally.

inherited_from \cDbDriverAbstract::__construct()

Parameters

$dbCfg

array

database configuration

Returns

Returns number of affected rows from last executed query (update, delete)

affectedRows() : int
see \cDbDriverAbstract::affectedRows

Returns

intNumber of affected rows

Builds a insert query.

buildInsert(string $tableName, array $fields) : string

String values in passed fields parameter will be escaped automatically.

see \cDbDriverAbstract::buildInsert

Parameters

$tableName

string

The table name

$fields

array

Associative array of fields to insert

Returns

stringThe INSERT SQL query

Builds a update query.

buildUpdate(string $tableName, array $fields, array $whereClauses) : string

String values in passed fields and whereClauses parameter will be escaped automatically.

see \cDbDriverAbstract::buildUpdate

Parameters

$tableName

string

The table name

$fields

array

Assoziative array of fields to update

$whereClauses

array

Assoziative array of field in where clause. Multiple entries will be concatenated with AND

Returns

stringThe UPDATE query

Abstract method for checking database driver base functions.

check() : bool

If this check fails, the database connection will not be established.

see \cDbDriverAbstract::check

Returns

bool

Connects to the database.

connect() : object | resource | int | null
see \cDbDriverAbstract::connect

Returns

objectresourceintnullConnection handler. Return value depends on used driver and is null in case of an error.

Closes the connection and frees the query id.

disconnect() : void

Escape string for using in SQL-Statement.

escape(string $string) : string
see \cDbDriverAbstract::escape

Parameters

$string

string

The string to escape

Returns

stringEscaped string

Discard the query result

free() : int
see \cDbDriverAbstract::free

Returns

int

Returns error message of last occured error by using databases interface.

getErrorMessage() : string

Returns error code of last occured error by using databases interface.

getErrorNumber() : int

Returns the database driver handler instance.

getHandler() : \cDbDriverHandler | null
Inherited
inherited_from \cDbDriverAbstract::getHandler()

Returns

This method returns the current result set as object or null if no result set is left.

getResultObject($className) : object

If optional param $className is set, the result object is an instance of class $className.

see \cDbDriverAbstract::getResultObject

Parameters

$className

Returns

object

Fetches server information.

getServerInfo() : array

Fetches all table names.

getTableNames() : array

Moves the result to the next record, if exists and returns the status of the movement

nextRecord() : int
see \cDbDriverAbstract::nextRecord

Returns

intFlag about move status 1 on success or 0

Returns the number of fields (columns) from current record set

numFields() : int
see \cDbDriverAbstract::numFields

Returns

intNumber of fields

Returns the number of rows from last executed select query.

numRows() : int
see \cDbDriverAbstract::numRows

Returns

intThe number of rows from last select query result

Executes the query.

query($query) : void
see \cDbDriverAbstract::query

Parameters

$query

Moves the cursor (position inside current result sets).

seek($pos) : void
see \cDbDriverAbstract::seek

Parameters

$pos

Sets the database driver handler.

setHandler(\cDbDriverHandler $handler) : void
Inherited
inherited_from \cDbDriverAbstract::setHandler()

Parameters

$handler

\cDbDriverHandler

database driver handler instance

 Properties

 

$_dataTypes 
 

$_dbCfg : array
Inherited
inherited_from \cDbDriverAbstract::$$_dbCfg
 

$_handler : \cDbDriverHandler
Inherited
inherited_from \cDbDriverAbstract::$$_handler