PHP code example of sjdskl / dbpool

1. Go to this page and download the library: Download sjdskl/dbpool 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/ */

    

sjdskl / dbpool example snippets

$xslt
$client = DbPool\Client\DbPoolClient::getInstance('127.0.0.1', AF_INET, 1122);
for($i = 0; $i < 10; $i ++) {
    $res = $client->query('select * from test.bairong where id=' . ($i + 1) . ' limit 1;')->fetchAll(\PDO::FETCH_ASSOC)->excute();
    print_r($res);
}

$res = $client->select('bairong', ['id', 'realname', 'phone'], ['id[<=]' => 10])->excute();
$xslt
$server = new \DbPool\Server\DbPoolServer('127.0.0.1', AF_INET, 1122);

//$server = new \DbPool\Server\DbPoolServer('/tmp/skl.sock', AF_UNIX);

$server->loop();
$xslt
$client->action(function() use ($client) {
    $client->update('bairong', ['realname' => '你大爷xxxx'], [
        'id' => 1,
    ])->excute();
    //true -> ommit,false -> rollback, just like medoo
    return true;
});