adodb-borland_ibase.inc.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. Support Borland Interbase 6.5 and later
  12. */
  13. // security - hide paths
  14. if (!defined('ADODB_DIR')) die();
  15. include_once(ADODB_DIR."/drivers/adodb-ibase.inc.php");
  16. class ADODB_borland_ibase extends ADODB_ibase {
  17. var $databaseType = "borland_ibase";
  18. function BeginTrans()
  19. {
  20. if ($this->transOff) return true;
  21. $this->transCnt += 1;
  22. $this->autoCommit = false;
  23. $this->_transactionID = ibase_trans($this->ibasetrans, $this->_connectionID);
  24. return $this->_transactionID;
  25. }
  26. function ServerInfo()
  27. {
  28. $arr['dialect'] = $this->dialect;
  29. switch($arr['dialect']) {
  30. case '':
  31. case '1': $s = 'Interbase 6.5, Dialect 1'; break;
  32. case '2': $s = 'Interbase 6.5, Dialect 2'; break;
  33. default:
  34. case '3': $s = 'Interbase 6.5, Dialect 3'; break;
  35. }
  36. $arr['version'] = '6.5';
  37. $arr['description'] = $s;
  38. return $arr;
  39. }
  40. // Note that Interbase 6.5 uses ROWS instead - don't you love forking wars!
  41. // SELECT col1, col2 FROM table ROWS 5 -- get 5 rows
  42. // SELECT col1, col2 FROM TABLE ORDER BY col1 ROWS 3 TO 7 -- first 5 skip 2
  43. // Firebird uses
  44. // SELECT FIRST 5 SKIP 2 col1, col2 FROM TABLE
  45. function SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0)
  46. {
  47. $nrows = (int) $nrows;
  48. $offset = (int) $offset;
  49. if ($nrows > 0) {
  50. if ($offset <= 0) $str = " ROWS $nrows ";
  51. else {
  52. $a = $offset+1;
  53. $b = $offset+$nrows;
  54. $str = " ROWS $a TO $b";
  55. }
  56. } else {
  57. // ok, skip
  58. $a = $offset + 1;
  59. $str = " ROWS $a TO 999999999"; // 999 million
  60. }
  61. $sql .= $str;
  62. return ($secs2cache) ?
  63. $this->CacheExecute($secs2cache,$sql,$inputarr)
  64. :
  65. $this->Execute($sql,$inputarr);
  66. }
  67. };
  68. class ADORecordSet_borland_ibase extends ADORecordSet_ibase {
  69. var $databaseType = "borland_ibase";
  70. function __construct($id,$mode=false)
  71. {
  72. parent::__construct($id,$mode);
  73. }
  74. }