Skip to content
This repository was archived by the owner on Apr 6, 2019. It is now read-only.

[Class] MultiDatabasePDOStatement

WulfGamesYT edited this page Mar 30, 2019 · 10 revisions

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)

$pdoDatabases
The array of PDO connections for each prepared statement to be run with.

$query
The SQL query

PLEASE NOTE: You won't need to use new MultiDatabasePDOStatement() in your code, instead can use the prepare method in the MultiDatabasePDO class which will return a new instance of this MultiDatabasePDOStatement class.

Function: bindValue

public function bindValue($nameOrNumber, $value)

$nameOrNumber
The name or number of the placeholder (must precede with a colon ':' if using a string placeholder).

$value
The variable or value to pass to the placeholder.

Function: bindValues

public function bindValues(array $items)

$items
The 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

$insertMode
Whether 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)

$limit
The amount of rows you want. If you pass in -1 then it will return all rows (or PHP_INT_MAX).

$offset
The optional offset, for example passing in 2 will remove the first two rows.

Function: sortBy

public function sortBy(string $column, string $direction)

$column
The name of the column in your table(s) that you want to sort by.

$direction
The order you want your results (numbers or strings/objects) to be ordered by, must be either ASC or DESC.