[Class] MultiDatabasePDOStatement - WulfGamesYT/MultiDatabasePDO GitHub Wiki
Here is the list of all the functions in the latest version. WARNING: Some functions might not be available/work differently in older versions.
Constructor
public function __construct(array $pdoDatabases, string $query)
$pdoDatabasesThe array of PDO connections for each prepared statement to be run with.
$queryThe SQL query
PLEASE NOTE: You won't need to use
new MultiDatabasePDOStatement()
in your code, instead can use theprepare
method in theMultiDatabasePDO
class which will return a new instance of thisMultiDatabasePDOStatement
class.
Function: bindValue
public function bindValue($nameOrNumber, $value)
$nameOrNumberThe name or number of the placeholder (must precede with a colon ':' if using a string placeholder).
$valueThe variable or value to pass to the placeholder.
Function: bindValues
public function bindValues(array $items)
$itemsThe associative array of placeholders and values, for each item in the associative array it will call the
bindValue
method.
Function: execute
public function execute(bool $insertMode = false, string $table = "") : bool
$insertModeWhether or not you are running an
INSERT
query. If you're not inserting data don't pass any parameters into this method.
**$table **If
$insertMode
is set to true, you will need to supply the name of the table you are inserting data into. Never trust user input as SQL injection can occur here!
Returns true if all the queries to each database table were successful.
Function: rowCount
public function rowCount() : int
Returns the amount of rows there are currently from the prepared statements.
Function: getAllRows
public function getAllRows() : array
Fetches all the current rows.
Function: getNextRow
public function getNextRow() : ?array
Returns the next row from the prepared statements, if there isn't another row it will return
null
.
Function: limitTo
public function limitTo(int $limit, int $offset = 0)
$limitThe amount of rows you want. If you pass in
-1
then it will return all rows (orPHP_INT_MAX
).
$offsetThe optional offset, for example passing in
2
will remove the first two rows.
Function: sortBy
public function sortBy(string $column, string $direction)
$columnThe name of the column in your table(s) that you want to sort by.
$directionThe order you want your results (numbers or strings/objects) to be ordered by, must be either
ASC
orDESC
.