mysql_poole_client_test.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. \app\lib\boot::init();
  11. $config = \app\lib\GlobConfigs::getKey('pgsqlpoole');
  12. $client = new swoole_client(SWOOLE_SOCK_TCP);
  13. $rts= $client->connect('192.168.2.200', $config['poole_port'], 10) or die("连接失败");//链接mysql客户端
  14. if (!$rts){
  15. die("连接发生错误,操作中止\n");
  16. }
  17. $sql =("select * from members where id=57111");
  18. $client->send($sql);
  19. $resdata = $client->recv();
  20. print_r(json_decode($resdata,true)) ;
  21. $sql ="update members set name='12-".rand(100,500)."' where id=57000";
  22. $client->send($sql);
  23. $resdata = $client->recv();
  24. print_r(json_decode($resdata,true)) ;
  25. $sql ="select * from \"districts\" where id=1";
  26. $client->send($sql);
  27. $resdata = $client->recv();
  28. print_r(json_decode($resdata,true)) ;
  29. /*
  30. $sql ="select * from \"districts\" where id>=1 and id<=300" ;
  31. $client->send($sql);
  32. $resdata = $client->recv();
  33. print_r(json_decode($resdata,true)) ;
  34. */
  35. $client->close();
  36. /*
  37. echo "收到: ".$resdata."\n" ;
  38. $resda=json_decode($resdata,true);
  39. $client->close();
  40. return json_encode($resda);
  41. */