PageRenderTime 41ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/include/adodb/tests/testmssql.php

https://github.com/radicaldesigns/amp
PHP | 76 lines | 39 code | 18 blank | 19 comment | 0 complexity | 42d3c87eccc7087385a0956a6d008634 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. <?php
  2. /**
  3. * @version V4.50 6 July 2004 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved.
  4. * Released under both BSD license and Lesser GPL library license.
  5. * Whenever there is any discrepancy between the two licenses,
  6. * the BSD license will take precedence.
  7. *
  8. * Set tabs to 4 for best viewing.
  9. *
  10. * Latest version is available at http://php.weblogs.com
  11. *
  12. * Test GetUpdateSQL and GetInsertSQL.
  13. */
  14. error_reporting(E_ALL);
  15. include('../adodb.inc.php');
  16. include('../tohtml.inc.php');
  17. //==========================
  18. // This code tests an insert
  19. $conn = &ADONewConnection("mssql"); // create a connection
  20. $conn->Connect('127.0.0.1','adodb','natsoft','northwind') or die('Fail');
  21. $conn->debug =1;
  22. $query = 'select * from products';
  23. $conn->SetFetchMode(ADODB_FETCH_ASSOC);
  24. $rs = $conn->Execute($query);
  25. echo "<pre>";
  26. while( !$rs->EOF ) {
  27. $output[] = $rs->fields;
  28. var_dump($rs->fields);
  29. $rs->MoveNext();
  30. print "<p>";
  31. }
  32. die();
  33. $p = $conn->Prepare('insert into products (productname,unitprice,dcreated) values (?,?,?)');
  34. echo "<pre>";
  35. print_r($p);
  36. $conn->debug=1;
  37. $conn->Execute($p,array('John'.rand(),33.3,$conn->DBDate(time())));
  38. $p = $conn->Prepare('select * from products where productname like ?');
  39. $arr = $conn->getarray($p,array('V%'));
  40. print_r($arr);
  41. die();
  42. //$conn = &ADONewConnection("mssql");
  43. //$conn->Connect('mangrove','sa','natsoft','ai');
  44. //$conn->Connect('mangrove','sa','natsoft','ai');
  45. $conn->debug=1;
  46. $conn->Execute('delete from blobtest');
  47. $conn->Execute('insert into blobtest (id) values(1)');
  48. $conn->UpdateBlobFile('blobtest','b1','../cute_icons_for_site/adodb.gif','id=1');
  49. $rs = $conn->Execute('select b1 from blobtest where id=1');
  50. $output = "c:\\temp\\test_out-".date('H-i-s').".gif";
  51. print "Saving file <b>$output</b>, size=".strlen($rs->fields[0])."<p>";
  52. $fd = fopen($output, "wb");
  53. fwrite($fd, $rs->fields[0]);
  54. fclose($fd);
  55. print " <a href=file://$output>View Image</a>";
  56. //$rs = $conn->Execute('SELECT id,SUBSTRING(b1, 1, 10) FROM blobtest');
  57. //rs2html($rs);
  58. ?>