PageRenderTime 42ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/include/adodb/tests/tmssql.php

https://github.com/radicaldesigns/amp
PHP | 80 lines | 65 code | 14 blank | 1 comment | 6 complexity | 3d7a43b2eb78e4442b082da5a04e42b7 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. error_reporting(E_ALL);
  3. ini_set('mssql.datetimeconvert',0);
  4. function tmssql()
  5. {
  6. print "<h3>mssql</h3>";
  7. $db = mssql_connect('JAGUAR\vsdotnet','adodb','natsoft') or die('No Connection');
  8. mssql_select_db('northwind',$db);
  9. $rs = mssql_query('select getdate() as date',$db);
  10. $o = mssql_fetch_row($rs);
  11. print_r($o);
  12. mssql_free_result($rs);
  13. print "<p>Delete</p>"; flush();
  14. $rs2 = mssql_query('delete from adoxyz',$db);
  15. $p = mssql_num_rows($rs2);
  16. mssql_free_result($rs2);
  17. }
  18. function tpear()
  19. {
  20. include_once('DB.php');
  21. print "<h3>PEAR</h3>";
  22. $username = 'adodb';
  23. $password = 'natsoft';
  24. $hostname = 'JAGUAR\vsdotnet';
  25. $databasename = 'northwind';
  26. $dsn = "mssql://$username:$password@$hostname/$databasename";
  27. $conn = &DB::connect($dsn);
  28. print "date=".$conn->GetOne('select getdate()')."<br>";
  29. @$conn->query('create table tester (id integer)');
  30. print "<p>Delete</p>"; flush();
  31. $rs = $conn->query('delete from tester');
  32. print "date=".$conn->GetOne('select getdate()')."<br>";
  33. }
  34. function tadodb()
  35. {
  36. include_once('../adodb.inc.php');
  37. print "<h3>ADOdb</h3>";
  38. $conn = NewADOConnection('mssql');
  39. $conn->Connect('JAGUAR\vsdotnet','adodb','natsoft','northwind');
  40. // $conn->debug=1;
  41. print "date=".$conn->GetOne('select getdate()')."<br>";
  42. $conn->Execute('create table tester (id integer)');
  43. print "<p>Delete</p>"; flush();
  44. $rs = $conn->Execute('delete from tester');
  45. print "date=".$conn->GetOne('select getdate()')."<br>";
  46. }
  47. $ACCEPTIP = '127.0.0.1';
  48. $remote = $_SERVER["REMOTE_ADDR"];
  49. if (!empty($ACCEPTIP))
  50. if ($remote != '127.0.0.1' && $remote != $ACCEPTIP)
  51. die("Unauthorised client: '$remote'");
  52. ?>
  53. <a href=tmssql.php?do=tmssql>mssql</a>
  54. <a href=tmssql.php?do=tpear>pear</a>
  55. <a href=tmssql.php?do=tadodb>adodb</a>
  56. <?php
  57. if (!empty($_GET['do'])) {
  58. $do = $_GET['do'];
  59. switch($do) {
  60. case 'tpear':
  61. case 'tadodb':
  62. case 'tmssql':
  63. $do();
  64. }
  65. }
  66. ?>