1. Go to this page and download the library: Download easyswoole/mysqli library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
easyswoole / mysqli example snippets
use EasySwoole\Mysqli\Client;
use EasySwoole\Mysqli\Config;
use Swoole\Coroutine;
Coroutine\run(function (): void {
$client = new Client(new Config([
'host' => '127.0.0.1',
'port' => 3306,
'user' => 'test',
'password' => 'secret',
'database' => 'test',
'maxConnectTime' => 1.0,
'timeout' => 2.0,
'charset' => 'utf8mb4',
'compress' => true, // 协商启用 MySQL 经典协议的 zlib 压缩
]));
// 第二个参数为本次查询的总超时,包含必要的建连和结果读取。
$rows = $client->rawQuery('SELECT * FROM student WHERE id = 1', 0.5);
$statement = $client->prepare('SELECT * FROM student WHERE id = ?');
try {
$rows = $statement->execute([1], 0.5);
} finally {
$statement->close();
}
$client->close();
});
use EasySwoole\Mysqli\Transaction\TransactionStartFlags;
$client->mysqlClient()->begin_transaction();
$client->mysqlClient()->begin_transaction(TransactionStartFlags::ReadOnly);
$client->mysqlClient()->begin_transaction(TransactionStartFlags::ConsistentSnapshotReadWrite);
use EasySwoole\Mysqli\Transaction\TransactionCompletionFlags;
$client->mysqlClient()->commit(TransactionCompletionFlags::ChainNoRelease);
$client->mysqlClient()->rollback(TransactionCompletionFlags::NoChainNoRelease);
$client->mysqlClient()->commit(TransactionCompletionFlags::Release);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.