mysql_poole_client_test.php 956 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Administrator
  5. * Date: 2019/5/27
  6. * Time: 9:28
  7. */
  8. define('START_TIME', microtime(true));
  9. require __DIR__.'/../vendor/autoload.php';
  10. \datainf\lib\boot::init();
  11. $config = \datainf\lib\GlobConfigs::getKey('pgsqlpoole');
  12. $client = new swoole_client(SWOOLE_SOCK_TCP);
  13. $client->set(array(
  14. 'socket_buffer_size' => 1024*1024*8, //2M缓存区
  15. ));
  16. $rts= $client->connect('192.168.2.200', $config['poole_port'], 10) or die("连接失败");//链接mysql客户端
  17. $sql =("select * from account where id=83632");
  18. $client->send($sql);
  19. $resdata = $client->recv();
  20. print_r(json_decode($resdata,true)) ;
  21. /*
  22. $sql ="select * from \"districts\" where id>=1 and id<=300" ;
  23. $client->send($sql);
  24. $resdata = $client->recv();
  25. print_r(json_decode($resdata,true)) ;
  26. */
  27. $client->close();
  28. /*
  29. echo "收到: ".$resdata."\n" ;
  30. $resda=json_decode($resdata,true);
  31. $client->close();
  32. return json_encode($resda);
  33. */