<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/5/27
 * Time: 9:28
 */

define('START_TIME', microtime(true));
require __DIR__.'/../vendor/autoload.php';
\app\lib\boot::init();



$config  = \app\lib\GlobConfigs::getKey('pgsqlpoole');

$client    = new swoole_client(SWOOLE_SOCK_TCP);
$rts= $client->connect('192.168.2.200', $config['poole_port'], 10) or die("连接失败");//链接mysql客户端

if (!$rts){
    die("连接发生错误，操作中止\n");
}

$sql =("select  * from members where id=57111");
$client->send($sql);
$resdata = $client->recv();
print_r(json_decode($resdata,true)) ;


$sql ="update  members  set  name='12-".rand(100,500)."'  where id=57000";
$client->send($sql);
$resdata = $client->recv();
print_r(json_decode($resdata,true)) ;

$sql ="select  * from \"districts\" where id=1";
$client->send($sql);
$resdata = $client->recv();
print_r(json_decode($resdata,true)) ;


/*
$sql ="select  * from \"districts\" where id>=1 and id<=300" ;
$client->send($sql);
$resdata = $client->recv();
print_r(json_decode($resdata,true)) ;
*/





$client->close();




/*
echo "收到： ".$resdata."\n" ;
$resda=json_decode($resdata,true);
$client->close();
return json_encode($resda);
*/