j1b1x / asyncmedoo
There is no license information available for the latest version (dev-master) of this package.
dev-master
2023-12-30 12:36 UTC
Requires
- catfan/medoo: ^2.1.9
Requires (Dev)
- pocketmine/pocketmine-mp: ^5.0
This package is auto-updated.
Last update: 2024-12-30 02:32:11 UTC
README
A PocketMine-MP virion to execute PDO statements async using Medoo
Initialization
First you need to initialize the MySQL credentials, so just do:
\Jibix\AsyncMedoo\AsyncMedoo::initialize(new \Jibix\AsyncMedoo\MySQLCredentials( "database", "password", "user", "address", 3306 //port ));
Using the AsyncExecutor
Instead of manually starting an async task, you can simply use the async function, which automatically executes the provided task in the AsyncExecutor
private function dumpCoins(string $playerName): void{ \Jibix\AsyncMedoo\util\async( fn (\Medoo\Medoo $medoo): int => $medoo->get("users", ["coins"], ["name" => $playerName]), function (int $coins) use ($playerName): void{ var_dump("$playerName has $coins coins!"); } ); } $this->dumpCoins("Jibix YT"); //Output: "Jibix YT has 100 coins!"