libasynql
3.2.0
Asynchronous MySQL access library for PocketMine plugins.
|
Public Member Functions | |
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 () | |
close () | |
Represents a database connection or a group of database connections
Definition at line 31 of file DataConnector.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.
Implemented in DataConnectorImpl.
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{} |
Implemented in DataConnectorImpl.
executeChangeRaw | ( | string | $query, |
array | $args = [] , |
||
?callable | $onSuccess = null , |
||
?callable | $onError = null |
||
) |
Implemented in DataConnectorImpl.
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{} |
Implemented in DataConnectorImpl.
executeGenericRaw | ( | string | $query, |
array | $args = [] , |
||
?callable | $onSuccess = null , |
||
?callable | $onError = null |
||
) |
Implemented in DataConnectorImpl.
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{} |
Implemented in DataConnectorImpl.
executeInsertRaw | ( | string | $query, |
array | $args = [] , |
||
?callable | $onInserted = null , |
||
?callable | $onError = null |
||
) |
Implemented in DataConnectorImpl.
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{} |
Implemented in DataConnectorImpl.
executeSelectRaw | ( | string | $query, |
array | $args = [] , |
||
?callable | $onSelect = null , |
||
?callable | $onError = null |
||
) |
Implemented in DataConnectorImpl.
isLoggingQueries | ( | ) |
Returns whether the queries are being logged. Always returns false when libasynql is packaged.
Implemented in DataConnectorImpl.
loadQuery | ( | GenericStatement | $stmt | ) |
Loads a pre-formatted query.
GenericStatement | $stmt |
InvalidArgumentException | if the statement duplicates the name of one previously loaded |
Implemented in DataConnectorImpl.
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 |
Implemented in DataConnectorImpl.
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 |
Implemented in DataConnectorImpl.
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.
Implemented in DataConnectorImpl.