MariaDBConnection extends PDOConnection implements IDBConnection
Table of Contents
insert() | Build an insert query using a prepared statement. | string |
---|---|---|
update() | Build an update query using a prepared statement. | int |
delete() | Execute a delete query for a record using a compound key. | int |
selectdb() | Select the current database | void |
curdb() | Returns the current database being used | string |
forwardCursor() | Create a forward-only cursor. Used to stream database results. | Generator |
prepareIn() | This will prepare a list of integers or a single int for a prepared sql query. This returns '(?)' if $val is an int and '(?,?,...)' if $val is an int[]. if $val is an array and it is not all ints then an InvalidArgumentException is thrown. | string |
extractRow() | This will extract a columns prefixed by a prefix in prefixList. | array |
prepareOptions() | Prepare the options argument for use in a prepared statement | array |
allInt() | mixed |
Methods
insert()
Build an insert query using a prepared statement.
public
insert(
$table :
string
, $pairs :
array
)
: string
This will work for most queries, but if you need to do something super complicated, write your own sql...
Parameters
- $table : string
Table name
- $pairs : array
Column names and values map
Tags
Return values
string —last insert id for updates
update()
Build an update query using a prepared statement.
public
update(
$table :
string
, $pkPairs :
array
, $pairs :
array
[, $limit :
int
= 1 ]
)
: int
Parameters
- $table : string
Table name
- $pkPairs : array
list of [primary key => value] for locating records to update.
- $pairs : array
Column names and values map
- $limit : int = 1
Limit to this number
Tags
Return values
int —the number of affected rows
delete()
Execute a delete query for a record using a compound key.
public
delete(
$table :
string
, $pkPairs :
array
[, $limit :
int
= 1 ]
)
: int
Parameters
- $table : string
table name
- $pkPairs : array
primary key to value pairs
- $limit : int = 1
limit
Tags
Return values
int —Always returns 1.
selectdb()
Select the current database
public
selectdb(
$db :
string
)
: void
Parameters
- $db : string
Database name
curdb()
Returns the current database being used
public
curdb(
)
: string
Return values
string —Current database name
forwardCursor()
Create a forward-only cursor. Used to stream database results.
public
forwardCursor(
$statement :
string
[, $options :
mixed
= null ]
[, $scroll :
mixed
= false ]
)
: Generator
Parameters
- $statement : string
sql statement
- $options : mixed = null
bindings. object or array
- $scroll : mixed = false
scroll
Return values
Generator —Results rows
prepareIn()
This will prepare a list of integers or a single int for a prepared sql query. This returns '(?)' if $val is an int and '(?,?,...)' if $val is an int[]. if $val is an array and it is not all ints then an InvalidArgumentException is thrown.
public
prepareIn(
$val :
int|array
[, $allInt :
bool
= true ]
)
: string
Parameters
- $val : int|array
value to use
- $allInt : bool = true
set to false to toggle off int checking
Tags
Return values
string —in statement
extractRow()
This will extract a columns prefixed by a prefix in prefixList.
public
extractRow(
$prefixList :
array
, $data :
array
)
: array
The returned array will contain an array for each prefix in the list. If any columsn match the format prefixxxx the the column name will have the prefix removed and be added to the output list that matches the prefix in the list.
Parameters
- $prefixList : array
List of prefixes to extract
- $data : array
Row data
Return values
array —columns
prepareOptions()
Prepare the options argument for use in a prepared statement
protected
prepareOptions(
$options :
array|object
)
: array
Parameters
- $options : array|object
Return values
arrayallInt()
private
allInt(
$a :
array
)
: mixed
Parameters
- $a : array