PageRenderTime 60ms CodeModel.GetById 17ms RepoModel.GetById 2ms app.codeStats 0ms

/include/adodb/tests/client.php

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