including :
- redis
- mysqli
- pdo
composer require hongxunpan/db
$config = ['host' => '192.168.0.1'];
\HongXunPan\DB\Redis\Redis::setConfig($config, 'default');//array $config = [], $connectName = 'default', array $options = []
default setting
$default = [
'host' => '127.0.0.1',
'port' => 6379,
'timeout' => 0.0,
'reserved' => null,
'retryInterval' => 0,
'readTimeout' => 0.0
];
$res = \HongXunPan\DB\Redis\Redis::connection()->set('test', 'test');
$res = \HongXunPan\DB\Redis\Redis::connection('xxx')->getConnection()->set('test', 'test1');
$res = \HongXunPan\DB\Redis\Redis::connection('aaa')->incr('testIncr');
/** \Redis $res */
var_dump($res);
$config = [
'host' => '192.168.65.2',
'port' => 3306,
'username' => 'default',
'password' => 'secret',
'database' => '',
];
\HongXunPan\DB\Mysql\Mysqli\Mysqli::setConfig($config, 'default');
/** @var PDO $res */
$res = \HongXunPan\DB\Mysql\Mysqli\Mysqli::connection('default')->getConnection();
$res = \HongXunPan\DB\Mysql\Mysqli\Mysqli::getConnection();
var_dump($res);
$config = [
'host' => '192.168.65.2',
'port' => 3306,
'username' => 'default',
'password' => 'secret',
];
\HongXunPan\DB\Mysql\Pdo\Pdo::setConfig($config, 'default');
$res = \HongXunPan\DB\Mysql\Pdo\Pdo::connection('default')->getConnection();
$res = \HongXunPan\DB\Mysql\Pdo\Pdo::getConnection('default')
1.0.2
2022-10-15 fix connection() doc tips1.0.1
2022-10-13 fix singleton extends bug1.0.0
2022-10-13 version1, include redis & mysqli & pdo