testmssql.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /**
  3. * @version v5.20.17 31-Mar-2020
  4. * @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
  5. * @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
  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 4 for best viewing.
  11. *
  12. * Latest version is available at http://adodb.org/
  13. *
  14. * Test GetUpdateSQL and GetInsertSQL.
  15. */
  16. error_reporting(E_ALL);
  17. include('../adodb.inc.php');
  18. include('../tohtml.inc.php');
  19. //==========================
  20. // This code tests an insert
  21. $conn = ADONewConnection("mssql"); // create a connection
  22. $conn->Connect('127.0.0.1','adodb','natsoft','northwind') or die('Fail');
  23. $conn->debug =1;
  24. $query = 'select * from products';
  25. $conn->SetFetchMode(ADODB_FETCH_ASSOC);
  26. $rs = $conn->Execute($query);
  27. echo "<pre>";
  28. while( !$rs->EOF ) {
  29. $output[] = $rs->fields;
  30. var_dump($rs->fields);
  31. $rs->MoveNext();
  32. print "<p>";
  33. }
  34. die();
  35. $p = $conn->Prepare('insert into products (productname,unitprice,dcreated) values (?,?,?)');
  36. echo "<pre>";
  37. print_r($p);
  38. $conn->debug=1;
  39. $conn->Execute($p,array('John'.rand(),33.3,$conn->DBDate(time())));
  40. $p = $conn->Prepare('select * from products where productname like ?');
  41. $arr = $conn->getarray($p,array('V%'));
  42. print_r($arr);
  43. die();
  44. //$conn = ADONewConnection("mssql");
  45. //$conn->Connect('mangrove','sa','natsoft','ai');
  46. //$conn->Connect('mangrove','sa','natsoft','ai');
  47. $conn->debug=1;
  48. $conn->Execute('delete from blobtest');
  49. $conn->Execute('insert into blobtest (id) values(1)');
  50. $conn->UpdateBlobFile('blobtest','b1','../cute_icons_for_site/adodb.gif','id=1');
  51. $rs = $conn->Execute('select b1 from blobtest where id=1');
  52. $output = "c:\\temp\\test_out-".date('H-i-s').".gif";
  53. print "Saving file <b>$output</b>, size=".strlen($rs->fields[0])."<p>";
  54. $fd = fopen($output, "wb");
  55. fwrite($fd, $rs->fields[0]);
  56. fclose($fd);
  57. print " <a href=file://$output>View Image</a>";
  58. //$rs = $conn->Execute('SELECT id,SUBSTRING(b1, 1, 10) FROM blobtest');
  59. //rs2html($rs);