clientws4.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Administrator
  5. * Date: 2019/5/23
  6. * Time: 17:42
  7. */
  8. define('START_TIME', microtime(true));
  9. require __DIR__ . '/../vendor/autoload.php';
  10. \datainf\lib\boot::init();
  11. use App\Lib\ModelBase;
  12. //use Illuminate\Database\Capsule\Manager as DB;
  13. ModelBase::init();
  14. //var_dump($obj);
  15. //var_dump(DB::table('datainf_log')->where('id',766)->first());
  16. ModelBase::init()->getConnection()->disconnect();
  17. echo "---------------------\n\n\n";
  18. //$obj->getConnection()->disconnect();
  19. //var_dump(DB::table('datainf_log')->where('id',766)->first());
  20. $sql = "select * from datainf_log where id in (766,767) ";
  21. $pdo = ModelBase::init()->getConnection()->getPdo();
  22. foreach ($pdo->query($sql ) as $row) {
  23. print_r($row); //你可以用 echo($GLOBAL); 来看到这些值
  24. }
  25. /*
  26. try{
  27. ModelBase::beginTransaction();
  28. $model = new \App\Http\Model\StZqResult();
  29. $ret = $model->where(['id'=>4314])->first();
  30. print_r($ret);
  31. ModelBase::commit();
  32. }catch (\Exception $e){
  33. echo $e->getMessage();
  34. ModelBase::rollBack();
  35. }
  36. $model = new App\Lib\TestModel();
  37. $model->name = 'name_'.mt_rand(1000,99999) ;
  38. $model->sex = '男';
  39. $model->age = mt_rand(10,50);
  40. $ret = $model->save();
  41. print_r([$ret,$model->toArray()]);
  42. */
  43. /*
  44. function request_post($url = '', $param = '') {
  45. if (empty($url) || empty($param)) {
  46. return false;
  47. }
  48. $postUrl = $url;
  49. $curlPost = $param;
  50. $ch = curl_init();//初始化curl
  51. curl_setopt($ch, CURLOPT_URL,$postUrl);//抓取指定网页
  52. curl_setopt($ch, CURLOPT_HEADER, 0);//设置header
  53. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//要求结果为字符串且输出到屏幕上
  54. curl_setopt($ch, CURLOPT_POST, 1);//post提交方式
  55. curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
  56. $data = curl_exec($ch);//运行curl
  57. curl_close($ch);
  58. return $data;
  59. }
  60. $data=[
  61. 'token'=>'xxxx',
  62. 'ccav'=>'ccav',
  63. ];
  64. $ret = request_post('http://192.168.2.200:9093/abcd',$data);
  65. print_r($ret);
  66. */
  67. /*
  68. $str = '';
  69. $arr = json_decode($str,true);
  70. $arr2 = json_decode( $arr['0']['data'] ,true);
  71. foreach ($arr2 as $val){
  72. print_r($val);
  73. echo "\n\n";
  74. }
  75. */