PageRenderTime 61ms CodeModel.GetById 27ms RepoModel.GetById 1ms app.codeStats 0ms

/concrete/libraries/3rdparty/adodb/drivers/adodb-ads.inc.php

https://bitbucket.org/selfeky/xclusivescardwebsite
PHP | 796 lines | 538 code | 112 blank | 146 comment | 130 complexity | c7c7bdbe70ba9a4e541a032080c0a118 MD5 | raw file
  1. <?php
  2. /*
  3. (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
  4. Portions Copyright (c) 2007-2009, iAnywhere Solutions, Inc.
  5. All rights reserved. All unpublished rights reserved.
  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. NOTE: This driver requires the Advantage PHP client libraries, which
  11. can be downloaded for free via:
  12. http://devzone.advantagedatabase.com/dz/content.aspx?key=20
  13. DELPHI FOR PHP USERS:
  14. The following steps can be taken to utilize this driver from the
  15. CodeGear Delphi for PHP product:
  16. 1 - See note above, download and install the Advantage PHP client.
  17. 2 - Copy the following files to the Delphi for PHP\X.X\php\ext directory:
  18. ace32.dll
  19. axcws32.dll
  20. adsloc32.dll
  21. php_advantage.dll (rename the existing php_advantage.dll.5.x.x file)
  22. 3 - Add the following line to the Delphi for PHP\X.X\php\php.ini.template file:
  23. extension=php_advantage.dll
  24. 4 - To use: enter "ads" as the DriverName on a connection component, and set
  25. a Host property similar to "DataDirectory=c:\". See the Advantage PHP
  26. help file topic for ads_connect for details on connection path options
  27. and formatting.
  28. 5 - (optional) - Modify the Delphi for PHP\X.X\vcl\packages\database.packages.php
  29. file and add ads to the list of strings returned when registering the
  30. Database object's DriverName property.
  31. */
  32. // security - hide paths
  33. if (!defined('ADODB_DIR')) die();
  34. define("_ADODB_ADS_LAYER", 2 );
  35. /*--------------------------------------------------------------------------------------
  36. --------------------------------------------------------------------------------------*/
  37. class ADODB_ads extends ADOConnection {
  38. var $databaseType = "ads";
  39. var $fmt = "'m-d-Y'";
  40. var $fmtTimeStamp = "'Y-m-d H:i:s'";
  41. var $concat_operator = '';
  42. var $replaceQuote = "''"; // string to use to replace quotes
  43. var $dataProvider = "ads";
  44. var $hasAffectedRows = true;
  45. var $binmode = ODBC_BINMODE_RETURN;
  46. var $useFetchArray = false; // setting this to true will make array elements in FETCH_ASSOC mode case-sensitive
  47. // breaking backward-compat
  48. //var $longreadlen = 8000; // default number of chars to return for a Blob/Long field
  49. var $_bindInputArray = false;
  50. var $curmode = SQL_CUR_USE_DRIVER; // See sqlext.h, SQL_CUR_DEFAULT == SQL_CUR_USE_DRIVER == 2L
  51. var $_genSeqSQL = "create table %s (id integer)";
  52. var $_autocommit = true;
  53. var $_haserrorfunctions = true;
  54. var $_has_stupid_odbc_fetch_api_change = true;
  55. var $_lastAffectedRows = 0;
  56. var $uCaseTables = true; // for meta* functions, uppercase table names
  57. function ADODB_ads()
  58. {
  59. $this->_haserrorfunctions = ADODB_PHPVER >= 0x4050;
  60. $this->_has_stupid_odbc_fetch_api_change = ADODB_PHPVER >= 0x4200;
  61. }
  62. // returns true or false
  63. function _connect($argDSN, $argUsername, $argPassword, $argDatabasename)
  64. {
  65. global $php_errormsg;
  66. if (!function_exists('ads_connect')) return null;
  67. if ($this->debug && $argDatabasename && $this->databaseType != 'vfp') {
  68. ADOConnection::outp("For Advantage Connect(), $argDatabasename is not used. Place dsn in 1st parameter.");
  69. }
  70. if (isset($php_errormsg)) $php_errormsg = '';
  71. if ($this->curmode === false) $this->_connectionID = ads_connect($argDSN,$argUsername,$argPassword);
  72. else $this->_connectionID = ads_connect($argDSN,$argUsername,$argPassword,$this->curmode);
  73. $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
  74. if (isset($this->connectStmt)) $this->Execute($this->connectStmt);
  75. return $this->_connectionID != false;
  76. }
  77. // returns true or false
  78. function _pconnect($argDSN, $argUsername, $argPassword, $argDatabasename)
  79. {
  80. global $php_errormsg;
  81. if (!function_exists('ads_connect')) return null;
  82. if (isset($php_errormsg)) $php_errormsg = '';
  83. $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
  84. if ($this->debug && $argDatabasename) {
  85. ADOConnection::outp("For PConnect(), $argDatabasename is not used. Place dsn in 1st parameter.");
  86. }
  87. // print "dsn=$argDSN u=$argUsername p=$argPassword<br>"; flush();
  88. if ($this->curmode === false) $this->_connectionID = ads_connect($argDSN,$argUsername,$argPassword);
  89. else $this->_connectionID = ads_pconnect($argDSN,$argUsername,$argPassword,$this->curmode);
  90. $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
  91. if ($this->_connectionID && $this->autoRollback) @ads_rollback($this->_connectionID);
  92. if (isset($this->connectStmt)) $this->Execute($this->connectStmt);
  93. return $this->_connectionID != false;
  94. }
  95. // returns the Server version and Description
  96. function ServerInfo()
  97. {
  98. if (!empty($this->host) && ADODB_PHPVER >= 0x4300) {
  99. $stmt = $this->Prepare('EXECUTE PROCEDURE sp_mgGetInstallInfo()');
  100. $res = $this->Execute($stmt);
  101. if(!$res)
  102. print $this->ErrorMsg();
  103. else{
  104. $ret["version"]= $res->fields[3];
  105. $ret["description"]="Advantage Database Server";
  106. return $ret;
  107. }
  108. }
  109. else {
  110. return ADOConnection::ServerInfo();
  111. }
  112. }
  113. // returns true or false
  114. function CreateSequence( $seqname,$start=1)
  115. {
  116. $res = $this->Execute("CREATE TABLE $seqname ( ID autoinc( 1 ) ) IN DATABASE");
  117. if(!$res){
  118. print $this->ErrorMsg();
  119. return false;
  120. }
  121. else
  122. return true;
  123. }
  124. // returns true or false
  125. function DropSequence($seqname)
  126. {
  127. $res = $this->Execute("DROP TABLE $seqname");
  128. if(!$res){
  129. print $this->ErrorMsg();
  130. return false;
  131. }
  132. else
  133. return true;
  134. }
  135. // returns the generated ID or false
  136. // checks if the table already exists, else creates the table and inserts a record into the table
  137. // and gets the ID number of the last inserted record.
  138. function GenID($seqname,$start=1)
  139. {
  140. $go = $this->Execute("select * from $seqname");
  141. if (!$go){
  142. $res = $this->Execute("CREATE TABLE $seqname ( ID autoinc( 1 ) ) IN DATABASE");
  143. if(!res){
  144. print $this->ErrorMsg();
  145. return false;
  146. }
  147. }
  148. $res = $this->Execute("INSERT INTO $seqname VALUES( DEFAULT )");
  149. if(!$res){
  150. print $this->ErrorMsg();
  151. return false;
  152. }
  153. else{
  154. $gen = $this->Execute("SELECT LastAutoInc( STATEMENT ) FROM system.iota");
  155. $ret = $gen->fields[0];
  156. return $ret;
  157. }
  158. }
  159. function ErrorMsg()
  160. {
  161. if ($this->_haserrorfunctions) {
  162. if ($this->_errorMsg !== false) return $this->_errorMsg;
  163. if (empty($this->_connectionID)) return @ads_errormsg();
  164. return @ads_errormsg($this->_connectionID);
  165. } else return ADOConnection::ErrorMsg();
  166. }
  167. function ErrorNo()
  168. {
  169. if ($this->_haserrorfunctions) {
  170. if ($this->_errorCode !== false) {
  171. // bug in 4.0.6, error number can be corrupted string (should be 6 digits)
  172. return (strlen($this->_errorCode)<=2) ? 0 : $this->_errorCode;
  173. }
  174. if (empty($this->_connectionID)) $e = @ads_error();
  175. else $e = @ads_error($this->_connectionID);
  176. // bug in 4.0.6, error number can be corrupted string (should be 6 digits)
  177. // so we check and patch
  178. if (strlen($e)<=2) return 0;
  179. return $e;
  180. } else return ADOConnection::ErrorNo();
  181. }
  182. function BeginTrans()
  183. {
  184. if (!$this->hasTransactions) return false;
  185. if ($this->transOff) return true;
  186. $this->transCnt += 1;
  187. $this->_autocommit = false;
  188. return ads_autocommit($this->_connectionID,false);
  189. }
  190. function CommitTrans($ok=true)
  191. {
  192. if ($this->transOff) return true;
  193. if (!$ok) return $this->RollbackTrans();
  194. if ($this->transCnt) $this->transCnt -= 1;
  195. $this->_autocommit = true;
  196. $ret = ads_commit($this->_connectionID);
  197. ads_autocommit($this->_connectionID,true);
  198. return $ret;
  199. }
  200. function RollbackTrans()
  201. {
  202. if ($this->transOff) return true;
  203. if ($this->transCnt) $this->transCnt -= 1;
  204. $this->_autocommit = true;
  205. $ret = ads_rollback($this->_connectionID);
  206. ads_autocommit($this->_connectionID,true);
  207. return $ret;
  208. }
  209. // Returns tables,Views or both on succesfull execution. Returns
  210. // tables by default on succesfull execustion.
  211. function &MetaTables($ttype)
  212. {
  213. $recordSet1 = $this->Execute("select * from system.tables");
  214. if(!$recordSet1){
  215. print $this->ErrorMsg();
  216. return false;
  217. }
  218. $recordSet2 = $this->Execute("select * from system.views");
  219. if(!$recordSet2){
  220. print $this->ErrorMsg();
  221. return false;
  222. }
  223. $i=0;
  224. while (!$recordSet1->EOF){
  225. $arr["$i"] = $recordSet1->fields[0];
  226. $recordSet1->MoveNext();
  227. $i=$i+1;
  228. }
  229. if($ttype=='FALSE'){
  230. while (!$recordSet2->EOF){
  231. $arr["$i"] = $recordSet2->fields[0];
  232. $recordSet2->MoveNext();
  233. $i=$i+1;
  234. }
  235. return $arr;
  236. }
  237. elseif($ttype=='VIEWS'){
  238. while (!$recordSet2->EOF){
  239. $arrV["$i"] = $recordSet2->fields[0];
  240. $recordSet2->MoveNext();
  241. $i=$i+1;
  242. }
  243. return $arrV;
  244. }
  245. else{
  246. return $arr;
  247. }
  248. }
  249. function &MetaPrimaryKeys($table)
  250. {
  251. $recordSet = $this->Execute("select table_primary_key from system.tables where name='$table'");
  252. if(!$recordSet){
  253. print $this->ErrorMsg();
  254. return false;
  255. }
  256. $i=0;
  257. while (!$recordSet->EOF){
  258. $arr["$i"] = $recordSet->fields[0];
  259. $recordSet->MoveNext();
  260. $i=$i+1;
  261. }
  262. return $arr;
  263. }
  264. /*
  265. See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcdatetime_data_type_changes.asp
  266. / SQL data type codes /
  267. #define SQL_UNKNOWN_TYPE 0
  268. #define SQL_CHAR 1
  269. #define SQL_NUMERIC 2
  270. #define SQL_DECIMAL 3
  271. #define SQL_INTEGER 4
  272. #define SQL_SMALLINT 5
  273. #define SQL_FLOAT 6
  274. #define SQL_REAL 7
  275. #define SQL_DOUBLE 8
  276. #if (ODBCVER >= 0x0300)
  277. #define SQL_DATETIME 9
  278. #endif
  279. #define SQL_VARCHAR 12
  280. / One-parameter shortcuts for date/time data types /
  281. #if (ODBCVER >= 0x0300)
  282. #define SQL_TYPE_DATE 91
  283. #define SQL_TYPE_TIME 92
  284. #define SQL_TYPE_TIMESTAMP 93
  285. #define SQL_UNICODE (-95)
  286. #define SQL_UNICODE_VARCHAR (-96)
  287. #define SQL_UNICODE_LONGVARCHAR (-97)
  288. */
  289. function ODBCTypes($t)
  290. {
  291. switch ((integer)$t) {
  292. case 1:
  293. case 12:
  294. case 0:
  295. case -95:
  296. case -96:
  297. return 'C';
  298. case -97:
  299. case -1: //text
  300. return 'X';
  301. case -4: //image
  302. return 'B';
  303. case 9:
  304. case 91:
  305. return 'D';
  306. case 10:
  307. case 11:
  308. case 92:
  309. case 93:
  310. return 'T';
  311. case 4:
  312. case 5:
  313. case -6:
  314. return 'I';
  315. case -11: // uniqidentifier
  316. return 'R';
  317. case -7: //bit
  318. return 'L';
  319. default:
  320. return 'N';
  321. }
  322. }
  323. function &MetaColumns($table)
  324. {
  325. global $ADODB_FETCH_MODE;
  326. $false = false;
  327. if ($this->uCaseTables) $table = strtoupper($table);
  328. $schema = '';
  329. $this->_findschema($table,$schema);
  330. $savem = $ADODB_FETCH_MODE;
  331. $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
  332. /*if (false) { // after testing, confirmed that the following does not work becoz of a bug
  333. $qid2 = ads_tables($this->_connectionID);
  334. $rs = new ADORecordSet_ads($qid2);
  335. $ADODB_FETCH_MODE = $savem;
  336. if (!$rs) return false;
  337. $rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change;
  338. $rs->_fetch();
  339. while (!$rs->EOF) {
  340. if ($table == strtoupper($rs->fields[2])) {
  341. $q = $rs->fields[0];
  342. $o = $rs->fields[1];
  343. break;
  344. }
  345. $rs->MoveNext();
  346. }
  347. $rs->Close();
  348. $qid = ads_columns($this->_connectionID,$q,$o,strtoupper($table),'%');
  349. } */
  350. switch ($this->databaseType) {
  351. case 'access':
  352. case 'vfp':
  353. $qid = ads_columns($this->_connectionID);#,'%','',strtoupper($table),'%');
  354. break;
  355. case 'db2':
  356. $colname = "%";
  357. $qid = ads_columns($this->_connectionID, "", $schema, $table, $colname);
  358. break;
  359. default:
  360. $qid = @ads_columns($this->_connectionID,'%','%',strtoupper($table),'%');
  361. if (empty($qid)) $qid = ads_columns($this->_connectionID);
  362. break;
  363. }
  364. if (empty($qid)) return $false;
  365. $rs = new ADORecordSet_ads($qid);
  366. $ADODB_FETCH_MODE = $savem;
  367. if (!$rs) return $false;
  368. $rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change;
  369. $rs->_fetch();
  370. $retarr = array();
  371. /*
  372. $rs->fields indices
  373. 0 TABLE_QUALIFIER
  374. 1 TABLE_SCHEM
  375. 2 TABLE_NAME
  376. 3 COLUMN_NAME
  377. 4 DATA_TYPE
  378. 5 TYPE_NAME
  379. 6 PRECISION
  380. 7 LENGTH
  381. 8 SCALE
  382. 9 RADIX
  383. 10 NULLABLE
  384. 11 REMARKS
  385. */
  386. while (!$rs->EOF) {
  387. // adodb_pr($rs->fields);
  388. if (strtoupper(trim($rs->fields[2])) == $table && (!$schema || strtoupper($rs->fields[1]) == $schema)) {
  389. $fld = new ADOFieldObject();
  390. $fld->name = $rs->fields[3];
  391. $fld->type = $this->ODBCTypes($rs->fields[4]);
  392. // ref: http://msdn.microsoft.com/library/default.asp?url=/archive/en-us/dnaraccgen/html/msdn_odk.asp
  393. // access uses precision to store length for char/varchar
  394. if ($fld->type == 'C' or $fld->type == 'X') {
  395. if ($this->databaseType == 'access')
  396. $fld->max_length = $rs->fields[6];
  397. else if ($rs->fields[4] <= -95) // UNICODE
  398. $fld->max_length = $rs->fields[7]/2;
  399. else
  400. $fld->max_length = $rs->fields[7];
  401. } else
  402. $fld->max_length = $rs->fields[7];
  403. $fld->not_null = !empty($rs->fields[10]);
  404. $fld->scale = $rs->fields[8];
  405. $retarr[strtoupper($fld->name)] = $fld;
  406. } else if (sizeof($retarr)>0)
  407. break;
  408. $rs->MoveNext();
  409. }
  410. $rs->Close(); //-- crashes 4.03pl1 -- why?
  411. if (empty($retarr)) $retarr = false;
  412. return $retarr;
  413. }
  414. // Returns an array of columns names for a given table
  415. function &MetaColumnNames($table)
  416. {
  417. $recordSet = $this->Execute("select name from system.columns where parent='$table'");
  418. if(!$recordSet){
  419. print $this->ErrorMsg();
  420. return false;
  421. }
  422. else{
  423. $i=0;
  424. while (!$recordSet->EOF){
  425. $arr["FIELD$i"] = $recordSet->fields[0];
  426. $recordSet->MoveNext();
  427. $i=$i+1;
  428. }
  429. return $arr;
  430. }
  431. }
  432. function Prepare($sql)
  433. {
  434. if (! $this->_bindInputArray) return $sql; // no binding
  435. $stmt = ads_prepare($this->_connectionID,$sql);
  436. if (!$stmt) {
  437. // we don't know whether odbc driver is parsing prepared stmts, so just return sql
  438. return $sql;
  439. }
  440. return array($sql,$stmt,false);
  441. }
  442. /* returns queryID or false */
  443. function _query($sql,$inputarr=false)
  444. {
  445. GLOBAL $php_errormsg;
  446. if (isset($php_errormsg)) $php_errormsg = '';
  447. $this->_error = '';
  448. if ($inputarr) {
  449. if (is_array($sql)) {
  450. $stmtid = $sql[1];
  451. } else {
  452. $stmtid = ads_prepare($this->_connectionID,$sql);
  453. if ($stmtid == false) {
  454. $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
  455. return false;
  456. }
  457. }
  458. if (! ads_execute($stmtid,$inputarr)) {
  459. //@ads_free_result($stmtid);
  460. if ($this->_haserrorfunctions) {
  461. $this->_errorMsg = ads_errormsg();
  462. $this->_errorCode = ads_error();
  463. }
  464. return false;
  465. }
  466. } else if (is_array($sql)) {
  467. $stmtid = $sql[1];
  468. if (!ads_execute($stmtid)) {
  469. //@ads_free_result($stmtid);
  470. if ($this->_haserrorfunctions) {
  471. $this->_errorMsg = ads_errormsg();
  472. $this->_errorCode = ads_error();
  473. }
  474. return false;
  475. }
  476. } else
  477. {
  478. $stmtid = ads_exec($this->_connectionID,$sql);
  479. }
  480. $this->_lastAffectedRows = 0;
  481. if ($stmtid)
  482. {
  483. if (@ads_num_fields($stmtid) == 0) {
  484. $this->_lastAffectedRows = ads_num_rows($stmtid);
  485. $stmtid = true;
  486. } else {
  487. $this->_lastAffectedRows = 0;
  488. ads_binmode($stmtid,$this->binmode);
  489. ads_longreadlen($stmtid,$this->maxblobsize);
  490. }
  491. if ($this->_haserrorfunctions)
  492. {
  493. $this->_errorMsg = '';
  494. $this->_errorCode = 0;
  495. }
  496. else
  497. $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
  498. }
  499. else
  500. {
  501. if ($this->_haserrorfunctions) {
  502. $this->_errorMsg = ads_errormsg();
  503. $this->_errorCode = ads_error();
  504. } else
  505. $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
  506. }
  507. return $stmtid;
  508. }
  509. /*
  510. Insert a null into the blob field of the table first.
  511. Then use UpdateBlob to store the blob.
  512. Usage:
  513. $conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)');
  514. $conn->UpdateBlob('blobtable','blobcol',$blob,'id=1');
  515. */
  516. function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB')
  517. {
  518. $sql = "UPDATE $table SET $column=? WHERE $where";
  519. $stmtid = ads_prepare($this->_connectionID,$sql);
  520. if ($stmtid == false){
  521. $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
  522. return false;
  523. }
  524. if (! ads_execute($stmtid,array($val),array(SQL_BINARY) )){
  525. if ($this->_haserrorfunctions){
  526. $this->_errorMsg = ads_errormsg();
  527. $this->_errorCode = ads_error();
  528. }
  529. return false;
  530. }
  531. return TRUE;
  532. }
  533. // returns true or false
  534. function _close()
  535. {
  536. $ret = @ads_close($this->_connectionID);
  537. $this->_connectionID = false;
  538. return $ret;
  539. }
  540. function _affectedrows()
  541. {
  542. return $this->_lastAffectedRows;
  543. }
  544. }
  545. /*--------------------------------------------------------------------------------------
  546. Class Name: Recordset
  547. --------------------------------------------------------------------------------------*/
  548. class ADORecordSet_ads extends ADORecordSet {
  549. var $bind = false;
  550. var $databaseType = "ads";
  551. var $dataProvider = "ads";
  552. var $useFetchArray;
  553. var $_has_stupid_odbc_fetch_api_change;
  554. function ADORecordSet_ads($id,$mode=false)
  555. {
  556. if ($mode === false) {
  557. global $ADODB_FETCH_MODE;
  558. $mode = $ADODB_FETCH_MODE;
  559. }
  560. $this->fetchMode = $mode;
  561. $this->_queryID = $id;
  562. // the following is required for mysql odbc driver in 4.3.1 -- why?
  563. $this->EOF = false;
  564. $this->_currentRow = -1;
  565. //$this->ADORecordSet($id);
  566. }
  567. // returns the field object
  568. function &FetchField($fieldOffset = -1)
  569. {
  570. $off=$fieldOffset+1; // offsets begin at 1
  571. $o= new ADOFieldObject();
  572. $o->name = @ads_field_name($this->_queryID,$off);
  573. $o->type = @ads_field_type($this->_queryID,$off);
  574. $o->max_length = @ads_field_len($this->_queryID,$off);
  575. if (ADODB_ASSOC_CASE == 0) $o->name = strtolower($o->name);
  576. else if (ADODB_ASSOC_CASE == 1) $o->name = strtoupper($o->name);
  577. return $o;
  578. }
  579. /* Use associative array to get fields array */
  580. function Fields($colname)
  581. {
  582. if ($this->fetchMode & ADODB_FETCH_ASSOC) return $this->fields[$colname];
  583. if (!$this->bind) {
  584. $this->bind = array();
  585. for ($i=0; $i < $this->_numOfFields; $i++) {
  586. $o = $this->FetchField($i);
  587. $this->bind[strtoupper($o->name)] = $i;
  588. }
  589. }
  590. return $this->fields[$this->bind[strtoupper($colname)]];
  591. }
  592. function _initrs()
  593. {
  594. global $ADODB_COUNTRECS;
  595. $this->_numOfRows = ($ADODB_COUNTRECS) ? @ads_num_rows($this->_queryID) : -1;
  596. $this->_numOfFields = @ads_num_fields($this->_queryID);
  597. // some silly drivers such as db2 as/400 and intersystems cache return _numOfRows = 0
  598. if ($this->_numOfRows == 0) $this->_numOfRows = -1;
  599. //$this->useFetchArray = $this->connection->useFetchArray;
  600. $this->_has_stupid_odbc_fetch_api_change = ADODB_PHPVER >= 0x4200;
  601. }
  602. function _seek($row)
  603. {
  604. return false;
  605. }
  606. // speed up SelectLimit() by switching to ADODB_FETCH_NUM as ADODB_FETCH_ASSOC is emulated
  607. function &GetArrayLimit($nrows,$offset=-1)
  608. {
  609. if ($offset <= 0) {
  610. $rs =& $this->GetArray($nrows);
  611. return $rs;
  612. }
  613. $savem = $this->fetchMode;
  614. $this->fetchMode = ADODB_FETCH_NUM;
  615. $this->Move($offset);
  616. $this->fetchMode = $savem;
  617. if ($this->fetchMode & ADODB_FETCH_ASSOC) {
  618. $this->fields =& $this->GetRowAssoc(ADODB_ASSOC_CASE);
  619. }
  620. $results = array();
  621. $cnt = 0;
  622. while (!$this->EOF && $nrows != $cnt) {
  623. $results[$cnt++] = $this->fields;
  624. $this->MoveNext();
  625. }
  626. return $results;
  627. }
  628. function MoveNext()
  629. {
  630. if ($this->_numOfRows != 0 && !$this->EOF) {
  631. $this->_currentRow++;
  632. if ($this->_has_stupid_odbc_fetch_api_change)
  633. $rez = @ads_fetch_into($this->_queryID,$this->fields);
  634. else {
  635. $row = 0;
  636. $rez = @ads_fetch_into($this->_queryID,$row,$this->fields);
  637. }
  638. if ($rez) {
  639. if ($this->fetchMode & ADODB_FETCH_ASSOC) {
  640. $this->fields =& $this->GetRowAssoc(ADODB_ASSOC_CASE);
  641. }
  642. return true;
  643. }
  644. }
  645. $this->fields = false;
  646. $this->EOF = true;
  647. return false;
  648. }
  649. function _fetch()
  650. {
  651. if ($this->_has_stupid_odbc_fetch_api_change)
  652. $rez = @ads_fetch_into($this->_queryID,$this->fields);
  653. else {
  654. $row = 0;
  655. $rez = @ads_fetch_into($this->_queryID,$row,$this->fields);
  656. }
  657. if ($rez) {
  658. if ($this->fetchMode & ADODB_FETCH_ASSOC) {
  659. $this->fields =& $this->GetRowAssoc(ADODB_ASSOC_CASE);
  660. }
  661. return true;
  662. }
  663. $this->fields = false;
  664. return false;
  665. }
  666. function _close()
  667. {
  668. return @ads_free_result($this->_queryID);
  669. }
  670. }
  671. ?>