Properties

$mysqli

$mysqli : \mysqli

Type

\mysqli

$mysqli_stmt

$mysqli_stmt : \mysqli_stmt

Type

\mysqli_stmt

$mysqli_result

$mysqli_result : \mysqli_result

Type

\mysqli_result

$sqlLog

$sqlLog : string

Type

string

Methods

__construct()

__construct() 

Returns current data base handle from Store[System][SYSTEM_DBH].

If not exists: open database and store the new dbh in Store[System][SYSTEM_DBH]

Throws

\qfq\CodeException
\qfq\UserFormException

getRowCount()

getRowCount() : mixed

Return the number of rows returned by the last call to execute().

If execute() has never been called, returns FALSE.

Returns

mixed —

Number of rows returned by last call to execute(). If Database::execute() has never been called prior a call to this method, false is returned.

getEnumSetValueList()

getEnumSetValueList(string  $table, string  $columnName) : array

Get the values for a given ENUM or SET column

Parameters

string $table

name of the table

string $columnName

name of the column

Throws

\qfq\UserFormException

if the table or column does not exist, or is not of type ENUM or SET

Returns

array

getTableDefinition()

getTableDefinition(string  $table) : array

Get all column definitions for a table. Return Assoc Array:

Field Type Null Key Default Extra

id bigint(20) NO PRI NULL auto_increment name varchar(128) YES NULL firstname varchar(128) YES NULL gender enum('','male','female') NO male groups set('','a','b','c') NO a

Parameters

string $table

table to retrieve column definition from

Returns

array —

column definition of table as returned by SHOW FIELDS FROM as associative array.

sql()

sql(  $sql, string  $mode = ROW_REGULAR, array  $parameterArray = array(), string  $specificMessage = '', array  $keys = array()) : mixed|null

Fires query $sql and fetches result als assoc array (all modes but ROW_KEYS) or as num array (mode: ROW_EKYS). Throws exception.

$mode ROW_REGULAR: Return 2-dimensional assoc array. Every query row is one array row. ROW_IMPLODE_ALL: Return string. All cells of all rows imploded to one string. ROW_EXPECT_0: Return empty string if there is now record row, Else an exception. ROW_EXPECT_1: Return 1-dimensional assoc array if there are exact one row. Else an exception. ROW_EXPECT_0_1: Return empty string if there is no row. Return 1- dimensional assoc array if there is one row. Else an exception. ROW_EXPECT_GE_1: Like 'ROW_REGULAR'. Throws an exception if there is an empty resultset. ROW_KEYS: Return 2-dimensional num(!) array. Every query row is one array row. In $keys are the column names.

Parameters

$sql
string $mode
array $parameterArray
string $specificMessage
array $keys

Throws

\qfq\CodeException
\qfq\DbException

Returns

mixed|null —

If no record found, empty string ( ROW_EXPECT_0_1, ROW_EXPECT_1) or empty array (all other modes)

sqlKeys()

sqlKeys(  $sql, array  $keys) : array|boolean

Wrapper for sql(), to simplyfy access.

Parameters

$sql
array $keys

Throws

\qfq\DbException

Returns

array|boolean

getLastInsertId()

getLastInsertId() : string

Returns lastInsertId

Returns

string

dbConnect()

dbConnect() : \mysqli

Open mysqli database connection if not already done.

Throws

\qfq\UserFormException

Returns

\mysqli

getFieldDefinitionFromTable()

getFieldDefinitionFromTable(string  $table, string  $columnName) : array

Get database column definition.

If the column is not found in the table, an exception is thrown.

Parameters

string $table

name of the table

string $columnName

name of the column

Throws

\qfq\DbException

Returns

array —

the definition of the column as retrieved by Database::getTableDefinition().

closeMysqliStmt()

closeMysqliStmt() 

Close an optional open MySQLi Statement.

Throws

\qfq\DbException

prepareExecute()

prepareExecute(string  $sql, array  $parameterArray = array()) : integer|mixed

Execute a prepared SQL statement like SELECT, INSERT, UPDATE, DELETE, SHOW, .

..

Returns the number of selected rows (SELECT, SHOW, ..) or the affected rows (UPDATE) or the last insert id (INSERT)

Parameters

string $sql

SQL statement with prepared statement variable.

array $parameterArray

parameter array for prepared statement execution.

Throws

\qfq\CodeException
\qfq\DbException
\qfq\UserFormException

Returns

integer|mixed

dbLog()

dbLog(  $sql, array  $parameterArray = array()) : string

Decide if the SQL statement has to be logged.If yes, create a timestamp and do the log.

Parameters

$sql
array $parameterArray

Throws

\qfq\UserFormException

Returns

string

isSqlModify()

isSqlModify(  $sql) : boolean

Check if the given SQL Statement might modify data.

Parameters

$sql

Returns

boolean —

true is the statement might modify data, else: false

prepareBindParam()

prepareBindParam(  $arr) 

Parameters

$arr

fetchAll()

fetchAll(string  $mode = '', array  $keys = array()) : array|boolean|mixed|string

Fetch all rows of the result as associative array.

mode: ROW_IMPLODE_ALL: Return string. All cells of all rows imploded to one string. ROW_KEYS: Retrun num array with column names in $keys default: Return 2-dimensional assoc array

Parameters

string $mode
array $keys

Returns

array|boolean|mixed|string —

false in case of error. Empty string is returned if the query didn't yield any rows. All rows as Multi Assoc array if $mode!=IMPLODE_ALL. All rows and all columns imploded to one string if $mode=IMPLODE_ALL