libasynql  3.2.0
Asynchronous MySQL access library for PocketMine plugins.
DataConnector Interface Reference
Inheritance diagram for DataConnector:
DataConnectorImpl

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 ()
 

Detailed Description

Represents a database connection or a group of database connections

Definition at line 31 of file DataConnector.php.

Member Function Documentation

◆ close()

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()

executeChange ( string  $queryName,
array  $args = [],
?callable  $onSuccess = null,
?callable  $onError = null 
)

Executes a query that changes data.

Parameters
string$queryNamethe GenericPreparedStatement query name
mixed[]$args the variables as defined in the GenericPreparedStatement
callable | null$onSuccessan optional callback when the query has succeeded: function(int $affectedRows) : void{}
callable | null$onErroran optional callback when the query has failed: function(SqlError $error) : void{}

Implemented in DataConnectorImpl.

◆ executeChangeRaw()

executeChangeRaw ( string  $query,
array  $args = [],
?callable  $onSuccess = null,
?callable  $onError = null 
)

Implemented in DataConnectorImpl.

◆ executeGeneric()

executeGeneric ( string  $queryName,
array  $args = [],
?callable  $onSuccess = null,
?callable  $onError = null 
)

Executes a generic query that either succeeds or fails.

Parameters
string$queryNamethe GenericPreparedStatement query name
mixed[]$args the variables as defined in the GenericPreparedStatement
callable | null$onSuccessan optional callback when the query has succeeded: function() : void{}
callable | null$onErroran optional callback when the query has failed: function(SqlError $error) : void{}

Implemented in DataConnectorImpl.

◆ executeGenericRaw()

executeGenericRaw ( string  $query,
array  $args = [],
?callable  $onSuccess = null,
?callable  $onError = null 
)

Implemented in DataConnectorImpl.

◆ executeInsert()

executeInsert ( string  $queryName,
array  $args = [],
?callable  $onInserted = null,
?callable  $onError = null 
)

Executes an insert query that results in an insert ID.

Parameters
string$queryNamethe GenericPreparedStatement query name
mixed[]$args the variables as defined in the GenericPreparedStatement
callable | null$onInsertedan optional callback when the query has succeeded: function(int $insertId, callable $affectedRows) : void{}
callable | null$onErroran optional callback when the query has failed: function(SqlError $error) : void{}

Implemented in DataConnectorImpl.

◆ executeInsertRaw()

executeInsertRaw ( string  $query,
array  $args = [],
?callable  $onInserted = null,
?callable  $onError = null 
)

Implemented in DataConnectorImpl.

◆ executeSelect()

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.

Parameters
string$queryNamethe GenericPreparedStatement query name
mixed[]$args the variables as defined in the GenericPreparedStatement
callable | null$onSelectan optional callback when the query has succeeded: function(array[] $rows, SqlColumnInfo $columns) : void{}
callable | null$onErroran optional callback when the query has failed: function(SqlError $error) : void{}

Implemented in DataConnectorImpl.

◆ executeSelectRaw()

executeSelectRaw ( string  $query,
array  $args = [],
?callable  $onSelect = null,
?callable  $onError = null 
)

Implemented in DataConnectorImpl.

◆ isLoggingQueries()

isLoggingQueries ( )

Returns whether the queries are being logged. Always returns false when libasynql is packaged.

Returns
bool

Implemented in DataConnectorImpl.

◆ loadQuery()

loadQuery ( GenericStatement  $stmt)

Loads a pre-formatted query.

Parameters
GenericStatement$stmt
Exceptions
InvalidArgumentExceptionif the statement duplicates the name of one previously loaded

Implemented in DataConnectorImpl.

◆ loadQueryFile()

loadQueryFile (   $fh,
string  $fileName = null 
)

Loads pre-formatted queries from a readable stream resource.

The implementation will close the stream after reading.

Parameters
resource$fha stream that supports feof(), fgets() and fclose().
string$fileNamethe filename providing the stream, only used for debugging and documentation purposes
Exceptions
GenericStatementFileParseExceptionif the file contains a syntax error or compile error
InvalidArgumentExceptionif the file introduces statements that duplicate the names of those previously loaded

Implemented in DataConnectorImpl.

◆ setLoggingQueries()

setLoggingQueries ( bool  $loggingQueries)

Sets whether the queries are being logged. Only effective when libasynql is not packaged; does nothing if libasynql is packaged.

Parameters
bool$loggingQueries

Implemented in DataConnectorImpl.

◆ waitAll()

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.


The documentation for this interface was generated from the following file: