adodb-db2ora.inc.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. Set tabs to 4 for best viewing.
  10. Latest version is available at http://adodb.org/
  11. Microsoft Visual FoxPro data driver. Requires ODBC. Works only on MS Windows.
  12. */
  13. // security - hide paths
  14. if (!defined('ADODB_DIR')) die();
  15. include(ADODB_DIR."/drivers/adodb-db2.inc.php");
  16. if (!defined('ADODB_DB2OCI')){
  17. define('ADODB_DB2OCI',1);
  18. /**
  19. * Callback function for preg_replace in _colonscope()
  20. * @param array $p matched patterns
  21. * return string '?' if parameter replaced, :N if not
  22. */
  23. function _colontrack($p)
  24. {
  25. global $_COLONARR, $_COLONSZ;
  26. $v = (integer) substr($p[1], 1);
  27. if ($v > $_COLONSZ) return $p[1];
  28. $_COLONARR[] = $v;
  29. return '?';
  30. }
  31. /**
  32. * smart remapping of :0, :1 bind vars to ? ?
  33. * @param string $sql SQL statement
  34. * @param array $arr parameters
  35. * @return array
  36. */
  37. function _colonscope($sql,$arr)
  38. {
  39. global $_COLONARR,$_COLONSZ;
  40. $_COLONARR = array();
  41. $_COLONSZ = sizeof($arr);
  42. $sql2 = preg_replace_callback('/(:[0-9]+)/', '_colontrack', $sql);
  43. if (empty($_COLONARR)) return array($sql,$arr);
  44. foreach($_COLONARR as $k => $v) {
  45. $arr2[] = $arr[$v];
  46. }
  47. return array($sql2,$arr2);
  48. }
  49. class ADODB_db2oci extends ADODB_db2 {
  50. var $databaseType = "db2oci";
  51. var $sysTimeStamp = 'sysdate';
  52. var $sysDate = 'trunc(sysdate)';
  53. function _Execute($sql, $inputarr = false)
  54. {
  55. if ($inputarr) list($sql,$inputarr) = _colonscope($sql, $inputarr);
  56. return parent::_Execute($sql, $inputarr);
  57. }
  58. };
  59. class ADORecordSet_db2oci extends ADORecordSet_odbc {
  60. var $databaseType = "db2oci";
  61. function __construct($id,$mode=false)
  62. {
  63. return parent::__construct($id,$mode);
  64. }
  65. }
  66. } //define