client.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <html>
  2. <body bgcolor=white>
  3. <?php
  4. /**
  5. * @version v5.20.17 31-Mar-2020
  6. * @copyright (c) 2001-2013 John Lim (jlim#natsoft.com). All rights reserved.
  7. * @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
  8. * Released under both BSD license and Lesser GPL library license.
  9. Whenever there is any discrepancy between the two licenses,
  10. the BSD license will take precedence.
  11. *
  12. * set tabs to 8
  13. */
  14. // documentation on usage is at http://adodb.org/dokuwiki/doku.php?id=v5:proxy:proxy_index
  15. echo PHP_VERSION,'<br>';
  16. var_dump(parse_url('odbc_mssql://userserver/'));
  17. die();
  18. include('../adodb.inc.php');
  19. include('../tohtml.inc.php');
  20. function send2server($url,$sql)
  21. {
  22. $url .= '?sql='.urlencode($sql);
  23. print "<p>$url</p>";
  24. $rs = csv2rs($url,$err);
  25. if ($err) print $err;
  26. return $rs;
  27. }
  28. function print_pre($s)
  29. {
  30. print "<pre>";print_r($s);print "</pre>";
  31. }
  32. $serverURL = 'http://localhost/php/phplens/adodb/server.php';
  33. $testhttp = false;
  34. $sql1 = "insertz into products (productname) values ('testprod 1')";
  35. $sql2 = "insert into products (productname) values ('testprod 1')";
  36. $sql3 = "insert into products (productname) values ('testprod 2')";
  37. $sql4 = "delete from products where productid>80";
  38. $sql5 = 'select * from products';
  39. if ($testhttp) {
  40. print "<a href=#c>Client Driver Tests</a><p>";
  41. print "<h3>Test Error</h3>";
  42. $rs = send2server($serverURL,$sql1);
  43. print_pre($rs);
  44. print "<hr />";
  45. print "<h3>Test Insert</h3>";
  46. $rs = send2server($serverURL,$sql2);
  47. print_pre($rs);
  48. print "<hr />";
  49. print "<h3>Test Insert2</h3>";
  50. $rs = send2server($serverURL,$sql3);
  51. print_pre($rs);
  52. print "<hr />";
  53. print "<h3>Test Delete</h3>";
  54. $rs = send2server($serverURL,$sql4);
  55. print_pre($rs);
  56. print "<hr />";
  57. print "<h3>Test Select</h3>";
  58. $rs = send2server($serverURL,$sql5);
  59. if ($rs) rs2html($rs);
  60. print "<hr />";
  61. }
  62. print "<a name=c><h1>CLIENT Driver Tests</h1>";
  63. $conn = ADONewConnection('csv');
  64. $conn->Connect($serverURL);
  65. $conn->debug = true;
  66. print "<h3>Bad SQL</h3>";
  67. $rs = $conn->Execute($sql1);
  68. print "<h3>Insert SQL 1</h3>";
  69. $rs = $conn->Execute($sql2);
  70. print "<h3>Insert SQL 2</h3>";
  71. $rs = $conn->Execute($sql3);
  72. print "<h3>Select SQL</h3>";
  73. $rs = $conn->Execute($sql5);
  74. if ($rs) rs2html($rs);
  75. print "<h3>Delete SQL</h3>";
  76. $rs = $conn->Execute($sql4);
  77. print "<h3>Select SQL</h3>";
  78. $rs = $conn->Execute($sql5);
  79. if ($rs) rs2html($rs);
  80. /* EXPECTED RESULTS FOR HTTP TEST:
  81. Test Insert
  82. http://localhost/php/adodb/server.php?sql=insert+into+products+%28productname%29+values+%28%27testprod%27%29
  83. adorecordset Object
  84. (
  85. [dataProvider] => native
  86. [fields] =>
  87. [blobSize] => 64
  88. [canSeek] =>
  89. [EOF] => 1
  90. [emptyTimeStamp] =>
  91. [emptyDate] =>
  92. [debug] =>
  93. [timeToLive] => 0
  94. [bind] =>
  95. [_numOfRows] => -1
  96. [_numOfFields] => 0
  97. [_queryID] => 1
  98. [_currentRow] => -1
  99. [_closed] =>
  100. [_inited] =>
  101. [sql] => insert into products (productname) values ('testprod')
  102. [affectedrows] => 1
  103. [insertid] => 81
  104. )
  105. --------------------------------------------------------------------------------
  106. Test Insert2
  107. http://localhost/php/adodb/server.php?sql=insert+into+products+%28productname%29+values+%28%27testprod%27%29
  108. adorecordset Object
  109. (
  110. [dataProvider] => native
  111. [fields] =>
  112. [blobSize] => 64
  113. [canSeek] =>
  114. [EOF] => 1
  115. [emptyTimeStamp] =>
  116. [emptyDate] =>
  117. [debug] =>
  118. [timeToLive] => 0
  119. [bind] =>
  120. [_numOfRows] => -1
  121. [_numOfFields] => 0
  122. [_queryID] => 1
  123. [_currentRow] => -1
  124. [_closed] =>
  125. [_inited] =>
  126. [sql] => insert into products (productname) values ('testprod')
  127. [affectedrows] => 1
  128. [insertid] => 82
  129. )
  130. --------------------------------------------------------------------------------
  131. Test Delete
  132. http://localhost/php/adodb/server.php?sql=delete+from+products+where+productid%3E80
  133. adorecordset Object
  134. (
  135. [dataProvider] => native
  136. [fields] =>
  137. [blobSize] => 64
  138. [canSeek] =>
  139. [EOF] => 1
  140. [emptyTimeStamp] =>
  141. [emptyDate] =>
  142. [debug] =>
  143. [timeToLive] => 0
  144. [bind] =>
  145. [_numOfRows] => -1
  146. [_numOfFields] => 0
  147. [_queryID] => 1
  148. [_currentRow] => -1
  149. [_closed] =>
  150. [_inited] =>
  151. [sql] => delete from products where productid>80
  152. [affectedrows] => 2
  153. [insertid] => 0
  154. )
  155. [more stuff deleted]
  156. .
  157. .
  158. .
  159. */