\APIMySQLiDatabase

connection to a MySQLi database using MySQLii extension

Summary

Methods
Properties
Constants
__construct()
setLogger()
setPrefix()
prefix()
connect()
genId()
fetchRow()
fetchArray()
fetchBoth()
fetchObject()
getInsertId()
getRowsNum()
getAffectedRows()
close()
freeRecordSet()
error()
errno()
quoteString()
quote()
escape()
queryF()
query()
queryFromFile()
getFieldName()
getFieldType()
getFieldsNum()
getServerVersion()
$prefix
$logger
$allowWebChanges
$conn
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Properties

$prefix

$prefix : 

Prefix for tables in the database

Type

$logger

$logger : 

reference to a {@link APILogger} object

Type

— APILogger

$allowWebChanges

$allowWebChanges : 

If statements that modify the database are selected

Type

$conn

$conn : \APIDatabase|\MySQLii

Database connection

Type

\APIDatabase|\MySQLii —

Methods

__construct()

__construct() : 

APIDatabase constructor.

Returns

setLogger()

setLogger(\APILogger  logger) : 

assign a {@link APILogger} object to the database

Parameters

\APILogger logger

reference to a {@link APILogger} object

Returns

setPrefix()

setPrefix(  value) : 

set the prefix for tables in the database

Parameters

value

table prefix

Returns

prefix()

prefix(  tablename) : 

attach the prefix.'_' to a given tablename

if tablename is empty, only prefix will be returned

Parameters

tablename

tablename

Returns

prefixed tablename, just prefix if tablename is empty

connect()

connect(  selectdb = true) : 

connect to the database

Parameters

selectdb

select the database now?

Returns

successful?

genId()

genId(  sequence) : 

generate an ID for a new row

This is for compatibility only. Will always return 0, because MySQLi supports autoincrement for primary keys.

Parameters

sequence

name of the sequence from which to get the next ID

Returns

always 0, because MySQLi has support for autoincrement

fetchRow()

fetchRow(\mysqli_result  result) : array|bool

Get a result row as an enumerated array

Parameters

\mysqli_result result

Returns

array|bool —

false on end of data

fetchArray()

fetchArray(\mysqli_result  result) : array|bool

Fetch a result row as an associative array

Parameters

\mysqli_result result

Returns

array|bool —

false on end of data

fetchBoth()

fetchBoth(\mysqli_result  result) : array|bool

Fetch a result row as an associative array

Parameters

\mysqli_result result

Returns

array|bool —

false on end of data

fetchObject()

fetchObject(  result) : \stdClass|bool

APIMySQLiiDatabase::fetchObjected()

Parameters

result

Returns

\stdClass|bool —

false on end of data

getInsertId()

getInsertId() : 

Get the ID generated from the previous INSERT operation

Returns

getRowsNum()

getRowsNum(\mysqli_result  result) : 

Get number of rows in result

Parameters

\mysqli_result result

Returns

getAffectedRows()

getAffectedRows() : 

Get number of affected rows

Returns

close()

close() : 

Close MySQLi connection

Returns

freeRecordSet()

freeRecordSet(\mysqli_result  result) : 

will free all memory associated with the result identifier result.

Parameters

\mysqli_result result

result

Returns

error()

error() : 

Returns the text of the error message from previous MySQLi operation

Returns

Returns the error text from the last MySQLi function, or '' (the empty string) if no error occurred.

errno()

errno() : 

Returns the numerical value of the error message from previous MySQLi operation

Returns

Returns the error number from the last MySQLi function, or 0 (zero) if no error occurred.

quoteString()

quoteString(  str) : 

Returns escaped string text with single quotes around it to be safely stored in database

Parameters

str

unescaped string text

Returns

escaped string text with single quotes around

quote()

quote(  string) : 

Quotes a string for use in a query.

Parameters

string

string to quote/escape for use in query

Returns

escape()

escape(  string) : 

Escapes a string for use in a query. Does not add surrounding quotes.

Parameters

string

string to escape

Returns

queryF()

queryF(  sql,   limit,   start) : \mysqli_result|bool

perform a query on the database

Parameters

sql

a valid MySQLi query

limit

number of records to return

start

offset of first record to return

Returns

\mysqli_result|bool —

query result or FALSE if successful or TRUE if successful and no result

query()

query(  sql,   limit,   start) : 

perform a query

This method is empty and does nothing! It should therefore only be used if nothing is exactly what you want done! ;-)

Parameters

sql

a valid MySQLi query

limit

number of records to return

start

offset of first record to return

Returns

queryFromFile()

queryFromFile(  file) : 

perform queries from SQL dump file in a batch

Parameters

file

file path to an SQL dump file

Returns

FALSE if failed reading SQL file or TRUE if the file has been read and queries executed

getFieldName()

getFieldName(\mysqli_result  result,   offset) : 

Get field name

Parameters

\mysqli_result result

query result

offset

numerical field index

Returns

getFieldType()

getFieldType(\mysqli_result  result,   offset) : 

Get field type

Parameters

\mysqli_result result

query result

offset

numerical field index

Returns

getFieldsNum()

getFieldsNum(\mysqli_result  result) : 

Get number of fields in result

Parameters

\mysqli_result result

query result

Returns

getServerVersion()

getServerVersion() : 

getServerVersion get version of the MySQLi server

Returns