Interaction
Table of Contents
- $insertId : int|string|null
- $result : null|bool|mysqli_result
- checkIfExists() : bool
- Checks if a value exists in a table.
- checkIfUnique() : bool
- Checks if a value is already in a table. Can also ignore a dataset.
- countResults() : int
- Returns the number of results in the last query
- countTableEntries() : int
- Returns the number of datasets in a table
- getFullTable() : array<string|int, array<string|int, mixed>>
- Selects a full table or specified fields of it and returns the result as two dimensional array
- getInsertId() : int|string|null
- Returns the id of the last inserted element
- getTableWhere() : array<string|int, array<string|int, mixed>>
- Selects a full table of specified fields of it filtered with an additional where statement. It returns the result as two dimensional array
- mergeAsGroup() : array<string|int, array<string|int, mixed>>
- Converts the result of the last query into a grouped array
- resultToArray() : array<string|int, array<string|int, mixed>>
- Converts the result of the last query into an array and returns it
- resultToLine() : array<string|int, mixed>
- Returns one line of the last query
Properties
$insertId
public
int|string|null
$insertId
Last insert id
$result
public
null|bool|mysqli_result
$result
Result of the last query
Methods
checkIfExists()
Checks if a value exists in a table.
public
checkIfExists(string $table, string $field, mixed $value) : bool
Table and field names are inserted unescaped. Check your input.
Parameters
- $table : string
-
Name of the table to check in
- $field : string
-
Name of the field in that a value should exist
- $value : mixed
-
Value to check for
Return values
bool —True when exists
checkIfUnique()
Checks if a value is already in a table. Can also ignore a dataset.
public
checkIfUnique(string $table, string $field, mixed $value[, string $ignoreField = null ][, string $ignoreValue = null ]) : bool
Table and field names are inserted unescaped. Check your input.
Parameters
- $table : string
-
Name of the table to check in
- $field : string
-
Field to check in
- $value : mixed
-
Value to check for
- $ignoreField : string = null
-
field of a dataset to ignore
- $ignoreValue : string = null
-
value of the in the argument before defined field of the dataset to ignore
Return values
bool —True when not exists
countResults()
Returns the number of results in the last query
public
countResults() : int
Return values
int —Number of results in the last query
countTableEntries()
Returns the number of datasets in a table
public
countTableEntries(string $table) : int
Parameters
- $table : string
-
Name of the table in the database
Return values
int —Number of datasets in the specified table
getFullTable()
Selects a full table or specified fields of it and returns the result as two dimensional array
public
getFullTable(string $table[, string $fields = "*" ]) : array<string|int, array<string|int, mixed>>
Parameters
- $table : string
-
Name of the table in the database
- $fields : string = "*"
-
Fields to select. Formatted as in an SQL query ("*", "a, b, c"...)
Return values
array<string|int, array<string|int, mixed>> —A two dimensional array with the results of the select statement
getInsertId()
Returns the id of the last inserted element
public
getInsertId() : int|string|null
Return values
int|string|null —Id of the last inserted element
getTableWhere()
Selects a full table of specified fields of it filtered with an additional where statement. It returns the result as two dimensional array
public
getTableWhere(string $table[, string $fields = "*" ][, string $where = "" ][, string $types = "" ][, array<string|int, mixed> $values = [] ]) : array<string|int, array<string|int, mixed>>
Parameters
- $table : string
-
Name of the table in the database
- $fields : string = "*"
-
Fields to select. Formatted as in a SQL query ("*", "a, b, c"...)
- $where : string = ""
-
The where statement in the query. Formatted as in a SQL query (a = 4 AND c = 4...);
- $types : string = ""
-
String with the types. Conform to prepared statements ("ssis")
- $values : array<string|int, mixed> = []
-
The values to insert in the prepared statement
Return values
array<string|int, array<string|int, mixed>> —two dimensional array with table data
mergeAsGroup()
Converts the result of the last query into a grouped array
public
mergeAsGroup(string $groupBy[, string $subElement = null ]) : array<string|int, array<string|int, mixed>>
Parameters
- $groupBy : string
-
The field, by which the array is grouped by
- $subElement : string = null
-
If set, the only a sub element of the grouped element is returned
Return values
array<string|int, array<string|int, mixed>> —Results of the last query as two dimensional array with the index as thr groupBy value
resultToArray()
Converts the result of the last query into an array and returns it
public
resultToArray([mixed $out = [] ]) : array<string|int, array<string|int, mixed>>
Parameters
- $out : mixed = []
Return values
array<string|int, array<string|int, mixed>> —Results of the last query as two dimensional array
resultToLine()
Returns one line of the last query
public
resultToLine() : array<string|int, mixed>
Return values
array<string|int, mixed> —Line of the last result