PHP code example of szjcomo / mysqli-pool
1. Go to this page and download the library: Download szjcomo/mysqli-pool 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/ */
szjcomo / mysqli-pool example snippets
/**
easyswoole 3.3.0之前可以使用的版本
use EasySwoole\Mysqli\Config;
use EasySwoole\MysqliPool;
$config = new \szjcomo\mysqli\Config([
'host' => '127.0.0.1',
'port' => 3306,
'user' => 'xxx',
'password' => 'xxx',
'database' => 'xxx',
'prefix'=>'xxx',
'debug' =>true
]);
\szjcomo\mysqliPool\Mysql::getInstance()->register('default',$config);
go(function(){
$db = \szjcomo\mysqliPool\Mysql::defer('default');
$list = $db->name('admin_user')->select();
print_r($list);
});**/
/**
* easyswoole 3.3.0后必须使用的版本
*/
use szjcomo\mysqliPool\MysqlPool;
$config = new \EasySwoole\Pool\Config();
$arr = [
'host' => '192.168.1.107',
'port' => 3306,
'user' => 'xxx',
'password' => 'xxx',
'database' => 'xxx',
'prefix' => 'xxx',
'timeout' => 30,
'debug' => true,
'charset' => 'utf8'
];
$pool = new MysqlPool($config,$arr);
go(function() use ($pool) {
$model = $pool->defer();
$result = $model->name('admin_user')->where('id','in',[1,3,4])->select();
print_r($result);
print_r($pool->status());
});