libasynql
3.2.0
Asynchronous MySQL access library for PocketMine plugins.
|
Public Member Functions | |
__construct (Plugin $plugin, SqlThread $thread, ?string $placeHolder, bool $logQueries=false) | |
setLoggingQueries (bool $loggingQueries) | |
isLoggingQueries () | |
loadQueryFile ($fh, string $fileName=null) | |
loadQuery (GenericStatement $stmt) | |
executeGeneric (string $queryName, array $args=[], ?callable $onSuccess=null, ?callable $onError=null) | |
executeGenericRaw (string $query, array $args=[], ?callable $onSuccess=null, ?callable $onError=null) | |
executeChange (string $queryName, array $args=[], ?callable $onSuccess=null, ?callable $onError=null) | |
executeChangeRaw (string $query, array $args=[], ?callable $onSuccess=null, ?callable $onError=null) | |
executeInsert (string $queryName, array $args=[], ?callable $onInserted=null, ?callable $onError=null) | |
executeInsertRaw (string $query, array $args=[], ?callable $onInserted=null, ?callable $onError=null) | |
executeSelect (string $queryName, array $args=[], ?callable $onSelect=null, ?callable $onError=null) | |
executeSelectRaw (string $query, array $args=[], ?callable $onSelect=null, ?callable $onError=null) | |
waitAll () | |
checkResults () | |
close () | |
Definition at line 48 of file DataConnectorImpl.php.
__construct | ( | Plugin | $plugin, |
SqlThread | $thread, | ||
?string | $placeHolder, | ||
bool | $logQueries = false |
||
) |
Plugin | $plugin | |
SqlThread | $thread | the backend SqlThread to connect with |
null | string | $placeHolder | the backend-implementation-dependent placeholder. "?" for mysqli-based backends, null for PDO-based and SQLite3-based backends. |
bool | $logQueries |
Definition at line 69 of file DataConnectorImpl.php.
checkResults | ( | ) |
Definition at line 261 of file DataConnectorImpl.php.
close | ( | ) |
Closes the connection and/or all child connections. Remember to call this method when the plugin is disabled or the data provider is switched.
Implements DataConnector.
Definition at line 265 of file DataConnectorImpl.php.
executeChange | ( | string | $queryName, |
array | $args = [] , |
||
?callable | $onSuccess = null , |
||
?callable | $onError = null |
||
) |
Executes a query that changes data.
string | $queryName | the GenericPreparedStatement query name |
mixed[] | $args the variables as defined in the GenericPreparedStatement | |
callable | null | $onSuccess | an optional callback when the query has succeeded: function(int $affectedRows) : void{} |
callable | null | $onError | an optional callback when the query has failed: function(SqlError $error) : void{} |
Implements DataConnector.
Definition at line 118 of file DataConnectorImpl.php.
executeChangeRaw | ( | string | $query, |
array | $args = [] , |
||
?callable | $onSuccess = null , |
||
?callable | $onError = null |
||
) |
Implements DataConnector.
Definition at line 126 of file DataConnectorImpl.php.
executeGeneric | ( | string | $queryName, |
array | $args = [] , |
||
?callable | $onSuccess = null , |
||
?callable | $onError = null |
||
) |
Executes a generic query that either succeeds or fails.
string | $queryName | the GenericPreparedStatement query name |
mixed[] | $args the variables as defined in the GenericPreparedStatement | |
callable | null | $onSuccess | an optional callback when the query has succeeded: function() : void{} |
callable | null | $onError | an optional callback when the query has failed: function(SqlError $error) : void{} |
Implements DataConnector.
Definition at line 102 of file DataConnectorImpl.php.
executeGenericRaw | ( | string | $query, |
array | $args = [] , |
||
?callable | $onSuccess = null , |
||
?callable | $onError = null |
||
) |
Implements DataConnector.
Definition at line 110 of file DataConnectorImpl.php.
executeInsert | ( | string | $queryName, |
array | $args = [] , |
||
?callable | $onInserted = null , |
||
?callable | $onError = null |
||
) |
Executes an insert query that results in an insert ID.
string | $queryName | the GenericPreparedStatement query name |
mixed[] | $args the variables as defined in the GenericPreparedStatement | |
callable | null | $onInserted | an optional callback when the query has succeeded: function(int $insertId, callable $affectedRows) : void{} |
callable | null | $onError | an optional callback when the query has failed: function(SqlError $error) : void{} |
Implements DataConnector.
Definition at line 134 of file DataConnectorImpl.php.
executeInsertRaw | ( | string | $query, |
array | $args = [] , |
||
?callable | $onInserted = null , |
||
?callable | $onError = null |
||
) |
Implements DataConnector.
Definition at line 142 of file DataConnectorImpl.php.
executeSelect | ( | string | $queryName, |
array | $args = [] , |
||
?callable | $onSelect = null , |
||
?callable | $onError = null |
||
) |
Executes a select query that returns an SQL result set. This does not strictly need to be SELECT queries – reflection queries like MySQL's SHOW TABLES
query are also allowed.
string | $queryName | the GenericPreparedStatement query name |
mixed[] | $args the variables as defined in the GenericPreparedStatement | |
callable | null | $onSelect | an optional callback when the query has succeeded: function(array[] $rows, SqlColumnInfo $columns) : void{} |
callable | null | $onError | an optional callback when the query has failed: function(SqlError $error) : void{} |
Implements DataConnector.
Definition at line 150 of file DataConnectorImpl.php.
executeSelectRaw | ( | string | $query, |
array | $args = [] , |
||
?callable | $onSelect = null , |
||
?callable | $onError = null |
||
) |
Implements DataConnector.
Definition at line 158 of file DataConnectorImpl.php.
isLoggingQueries | ( | ) |
Returns whether the queries are being logged. Always returns false when libasynql is packaged.
Implements DataConnector.
Definition at line 83 of file DataConnectorImpl.php.
loadQuery | ( | GenericStatement | $stmt | ) |
Loads a pre-formatted query.
GenericStatement | $stmt |
InvalidArgumentException | if the statement duplicates the name of one previously loaded |
Implements DataConnector.
Definition at line 95 of file DataConnectorImpl.php.
loadQueryFile | ( | $fh, | |
string | $fileName = null |
||
) |
Loads pre-formatted queries from a readable stream resource.
The implementation will close the stream after reading.
resource | $fh | a stream that supports feof() , fgets() and fclose() . |
string | $fileName | the filename providing the stream, only used for debugging and documentation purposes |
GenericStatementFileParseException | if the file contains a syntax error or compile error |
InvalidArgumentException | if the file introduces statements that duplicate the names of those previously loaded |
Implements DataConnector.
Definition at line 87 of file DataConnectorImpl.php.
setLoggingQueries | ( | bool | $loggingQueries | ) |
Sets whether the queries are being logged. Only effective when libasynql is not packaged; does nothing if libasynql is packaged.
bool | $loggingQueries |
Implements DataConnector.
Definition at line 79 of file DataConnectorImpl.php.
waitAll | ( | ) |
This function waits all pending queries to complete then returns. This is as if the queries were executed in blocking mode (not async).
This method should only under very rare events like server start/stop. This should not be run trivially (e.g. every time player joins), because otherwise this is not async.
Implements DataConnector.
Definition at line 254 of file DataConnectorImpl.php.