PageRenderTime 51ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 1ms

/lib/rdfapi-php/api/util/adodb/drivers/adodb-odbc.inc.php

https://github.com/komagata/plnet
PHP | 726 lines | 497 code | 107 blank | 122 comment | 142 complexity | 1b3bd236ae3eae6539ea6200f59d58ad MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. /*
  3. V4.52 10 Aug 2004 (c) 2000-2004 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. Set tabs to 4 for best viewing.
  8. Latest version is available at http://adodb.sourceforge.net
  9. Requires ODBC. Works on Windows and Unix.
  10. */
  11. // security - hide paths
  12. if (!defined('ADODB_DIR')) die();
  13. define("_ADODB_ODBC_LAYER", 2 );
  14. /*--------------------------------------------------------------------------------------
  15. --------------------------------------------------------------------------------------*/
  16. class ADODB_odbc extends ADOConnection {
  17. var $databaseType = "odbc";
  18. var $fmtDate = "'Y-m-d'";
  19. var $fmtTimeStamp = "'Y-m-d, h:i:sA'";
  20. var $replaceQuote = "''"; // string to use to replace quotes
  21. var $dataProvider = "odbc";
  22. var $hasAffectedRows = true;
  23. var $binmode = ODBC_BINMODE_RETURN;
  24. var $useFetchArray = false; // setting this to true will make array elements in FETCH_ASSOC mode case-sensitive
  25. // breaking backward-compat
  26. //var $longreadlen = 8000; // default number of chars to return for a Blob/Long field
  27. var $_bindInputArray = false;
  28. var $curmode = SQL_CUR_USE_DRIVER; // See sqlext.h, SQL_CUR_DEFAULT == SQL_CUR_USE_DRIVER == 2L
  29. var $_genSeqSQL = "create table %s (id integer)";
  30. var $_autocommit = true;
  31. var $_haserrorfunctions = true;
  32. var $_has_stupid_odbc_fetch_api_change = true;
  33. var $_lastAffectedRows = 0;
  34. var $uCaseTables = true; // for meta* functions, uppercase table names
  35. function ADODB_odbc()
  36. {
  37. $this->_haserrorfunctions = ADODB_PHPVER >= 0x4050;
  38. $this->_has_stupid_odbc_fetch_api_change = ADODB_PHPVER >= 0x4200;
  39. }
  40. function ServerInfo()
  41. {
  42. if (!empty($this->host) && ADODB_PHPVER >= 0x4300) {
  43. $dsn = strtoupper($this->host);
  44. $first = true;
  45. $found = false;
  46. if (!function_exists('odbc_data_source')) return false;
  47. while(true) {
  48. $rez = @odbc_data_source($this->_connectionID,
  49. $first ? SQL_FETCH_FIRST : SQL_FETCH_NEXT);
  50. $first = false;
  51. if (!is_array($rez)) break;
  52. if (strtoupper($rez['server']) == $dsn) {
  53. $found = true;
  54. break;
  55. }
  56. }
  57. if (!$found) return ADOConnection::ServerInfo();
  58. if (!isset($rez['version'])) $rez['version'] = '';
  59. return $rez;
  60. } else {
  61. return ADOConnection::ServerInfo();
  62. }
  63. }
  64. function CreateSequence($seqname='adodbseq',$start=1)
  65. {
  66. if (empty($this->_genSeqSQL)) return false;
  67. $ok = $this->Execute(sprintf($this->_genSeqSQL,$seqname));
  68. if (!$ok) return false;
  69. $start -= 1;
  70. return $this->Execute("insert into $seqname values($start)");
  71. }
  72. var $_dropSeqSQL = 'drop table %s';
  73. function DropSequence($seqname)
  74. {
  75. if (empty($this->_dropSeqSQL)) return false;
  76. return $this->Execute(sprintf($this->_dropSeqSQL,$seqname));
  77. }
  78. /*
  79. This algorithm is not very efficient, but works even if table locking
  80. is not available.
  81. Will return false if unable to generate an ID after $MAXLOOPS attempts.
  82. */
  83. function GenID($seq='adodbseq',$start=1)
  84. {
  85. // if you have to modify the parameter below, your database is overloaded,
  86. // or you need to implement generation of id's yourself!
  87. $MAXLOOPS = 100;
  88. //$this->debug=1;
  89. while (--$MAXLOOPS>=0) {
  90. $num = $this->GetOne("select id from $seq");
  91. if ($num === false) {
  92. $this->Execute(sprintf($this->_genSeqSQL ,$seq));
  93. $start -= 1;
  94. $num = '0';
  95. $ok = $this->Execute("insert into $seq values($start)");
  96. if (!$ok) return false;
  97. }
  98. $this->Execute("update $seq set id=id+1 where id=$num");
  99. if ($this->affected_rows() > 0) {
  100. $num += 1;
  101. $this->genID = $num;
  102. return $num;
  103. }
  104. }
  105. if ($fn = $this->raiseErrorFn) {
  106. $fn($this->databaseType,'GENID',-32000,"Unable to generate unique id after $MAXLOOPS attempts",$seq,$num);
  107. }
  108. return false;
  109. }
  110. function ErrorMsg()
  111. {
  112. if ($this->_haserrorfunctions) {
  113. if ($this->_errorMsg !== false) return $this->_errorMsg;
  114. if (empty($this->_connectionID)) return @odbc_errormsg();
  115. return @odbc_errormsg($this->_connectionID);
  116. } else return ADOConnection::ErrorMsg();
  117. }
  118. function ErrorNo()
  119. {
  120. if ($this->_haserrorfunctions) {
  121. if ($this->_errorCode !== false) {
  122. // bug in 4.0.6, error number can be corrupted string (should be 6 digits)
  123. return (strlen($this->_errorCode)<=2) ? 0 : $this->_errorCode;
  124. }
  125. if (empty($this->_connectionID)) $e = @odbc_error();
  126. else $e = @odbc_error($this->_connectionID);
  127. // bug in 4.0.6, error number can be corrupted string (should be 6 digits)
  128. // so we check and patch
  129. if (strlen($e)<=2) return 0;
  130. return $e;
  131. } else return ADOConnection::ErrorNo();
  132. }
  133. // returns true or false
  134. function _connect($argDSN, $argUsername, $argPassword, $argDatabasename)
  135. {
  136. global $php_errormsg;
  137. if (!function_exists('odbc_connect')) return null;
  138. if ($this->debug && $argDatabasename && $this->databaseType != 'vfp') {
  139. ADOConnection::outp("For odbc Connect(), $argDatabasename is not used. Place dsn in 1st parameter.");
  140. }
  141. if (isset($php_errormsg)) $php_errormsg = '';
  142. if ($this->curmode === false) $this->_connectionID = odbc_connect($argDSN,$argUsername,$argPassword);
  143. else $this->_connectionID = odbc_connect($argDSN,$argUsername,$argPassword,$this->curmode);
  144. $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
  145. if (isset($this->connectStmt)) $this->Execute($this->connectStmt);
  146. //if ($this->_connectionID) odbc_autocommit($this->_connectionID,true);
  147. return $this->_connectionID != false;
  148. }
  149. // returns true or false
  150. function _pconnect($argDSN, $argUsername, $argPassword, $argDatabasename)
  151. {
  152. global $php_errormsg;
  153. if (!function_exists('odbc_connect')) return null;
  154. if (isset($php_errormsg)) $php_errormsg = '';
  155. $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
  156. if ($this->debug && $argDatabasename) {
  157. ADOConnection::outp("For odbc PConnect(), $argDatabasename is not used. Place dsn in 1st parameter.");
  158. }
  159. // print "dsn=$argDSN u=$argUsername p=$argPassword<br>"; flush();
  160. if ($this->curmode === false) $this->_connectionID = odbc_connect($argDSN,$argUsername,$argPassword);
  161. else $this->_connectionID = odbc_pconnect($argDSN,$argUsername,$argPassword,$this->curmode);
  162. $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
  163. if ($this->_connectionID && $this->autoRollback) @odbc_rollback($this->_connectionID);
  164. if (isset($this->connectStmt)) $this->Execute($this->connectStmt);
  165. return $this->_connectionID != false;
  166. }
  167. function BeginTrans()
  168. {
  169. if (!$this->hasTransactions) return false;
  170. if ($this->transOff) return true;
  171. $this->transCnt += 1;
  172. $this->_autocommit = false;
  173. return odbc_autocommit($this->_connectionID,false);
  174. }
  175. function CommitTrans($ok=true)
  176. {
  177. if ($this->transOff) return true;
  178. if (!$ok) return $this->RollbackTrans();
  179. if ($this->transCnt) $this->transCnt -= 1;
  180. $this->_autocommit = true;
  181. $ret = odbc_commit($this->_connectionID);
  182. odbc_autocommit($this->_connectionID,true);
  183. return $ret;
  184. }
  185. function RollbackTrans()
  186. {
  187. if ($this->transOff) return true;
  188. if ($this->transCnt) $this->transCnt -= 1;
  189. $this->_autocommit = true;
  190. $ret = odbc_rollback($this->_connectionID);
  191. odbc_autocommit($this->_connectionID,true);
  192. return $ret;
  193. }
  194. function MetaPrimaryKeys($table)
  195. {
  196. global $ADODB_FETCH_MODE;
  197. if ($this->uCaseTables) $table = strtoupper($table);
  198. $schema = '';
  199. $this->_findschema($table,$schema);
  200. $savem = $ADODB_FETCH_MODE;
  201. $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
  202. $qid = @odbc_primarykeys($this->_connectionID,'',$schema,$table);
  203. if (!$qid) {
  204. $ADODB_FETCH_MODE = $savem;
  205. return false;
  206. }
  207. $rs = new ADORecordSet_odbc($qid);
  208. $ADODB_FETCH_MODE = $savem;
  209. if (!$rs) return false;
  210. $rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change;
  211. $arr =& $rs->GetArray();
  212. $rs->Close();
  213. //print_r($arr);
  214. $arr2 = array();
  215. for ($i=0; $i < sizeof($arr); $i++) {
  216. if ($arr[$i][3]) $arr2[] = $arr[$i][3];
  217. }
  218. return $arr2;
  219. }
  220. function &MetaTables($ttype=false)
  221. {
  222. global $ADODB_FETCH_MODE;
  223. $savem = $ADODB_FETCH_MODE;
  224. $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
  225. $qid = odbc_tables($this->_connectionID);
  226. $rs = new ADORecordSet_odbc($qid);
  227. $ADODB_FETCH_MODE = $savem;
  228. if (!$rs) return false;
  229. $rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change;
  230. $arr =& $rs->GetArray();
  231. //print_r($arr);
  232. $rs->Close();
  233. $arr2 = array();
  234. if ($ttype) {
  235. $isview = strncmp($ttype,'V',1) === 0;
  236. }
  237. for ($i=0; $i < sizeof($arr); $i++) {
  238. if (!$arr[$i][2]) continue;
  239. $type = $arr[$i][3];
  240. if ($ttype) {
  241. if ($isview) {
  242. if (strncmp($type,'V',1) === 0) $arr2[] = $arr[$i][2];
  243. } else if (strncmp($type,'SYS',3) !== 0) $arr2[] = $arr[$i][2];
  244. } else if (strncmp($type,'SYS',3) !== 0) $arr2[] = $arr[$i][2];
  245. }
  246. return $arr2;
  247. }
  248. /*
  249. / SQL data type codes /
  250. #define SQL_UNKNOWN_TYPE 0
  251. #define SQL_CHAR 1
  252. #define SQL_NUMERIC 2
  253. #define SQL_DECIMAL 3
  254. #define SQL_INTEGER 4
  255. #define SQL_SMALLINT 5
  256. #define SQL_FLOAT 6
  257. #define SQL_REAL 7
  258. #define SQL_DOUBLE 8
  259. #if (ODBCVER >= 0x0300)
  260. #define SQL_DATETIME 9
  261. #endif
  262. #define SQL_VARCHAR 12
  263. / One-parameter shortcuts for date/time data types /
  264. #if (ODBCVER >= 0x0300)
  265. #define SQL_TYPE_DATE 91
  266. #define SQL_TYPE_TIME 92
  267. #define SQL_TYPE_TIMESTAMP 93
  268. #define SQL_UNICODE (-95)
  269. #define SQL_UNICODE_VARCHAR (-96)
  270. #define SQL_UNICODE_LONGVARCHAR (-97)
  271. */
  272. function ODBCTypes($t)
  273. {
  274. switch ((integer)$t) {
  275. case 1:
  276. case 12:
  277. case 0:
  278. case -95:
  279. case -96:
  280. return 'C';
  281. case -97:
  282. case -1: //text
  283. return 'X';
  284. case -4: //image
  285. return 'B';
  286. case 91:
  287. case 11:
  288. return 'D';
  289. case 92:
  290. case 93:
  291. case 9: return 'T';
  292. case 4:
  293. case 5:
  294. case -6:
  295. return 'I';
  296. case -11: // uniqidentifier
  297. return 'R';
  298. case -7: //bit
  299. return 'L';
  300. default:
  301. return 'N';
  302. }
  303. }
  304. function &MetaColumns($table)
  305. {
  306. global $ADODB_FETCH_MODE;
  307. if ($this->uCaseTables) $table = strtoupper($table);
  308. $schema = '';
  309. $this->_findschema($table,$schema);
  310. $savem = $ADODB_FETCH_MODE;
  311. $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
  312. /*if (false) { // after testing, confirmed that the following does not work becoz of a bug
  313. $qid2 = odbc_tables($this->_connectionID);
  314. $rs = new ADORecordSet_odbc($qid2);
  315. $ADODB_FETCH_MODE = $savem;
  316. if (!$rs) return false;
  317. $rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change;
  318. $rs->_fetch();
  319. while (!$rs->EOF) {
  320. if ($table == strtoupper($rs->fields[2])) {
  321. $q = $rs->fields[0];
  322. $o = $rs->fields[1];
  323. break;
  324. }
  325. $rs->MoveNext();
  326. }
  327. $rs->Close();
  328. $qid = odbc_columns($this->_connectionID,$q,$o,strtoupper($table),'%');
  329. } */
  330. switch ($this->databaseType) {
  331. case 'access':
  332. case 'vfp':
  333. $qid = odbc_columns($this->_connectionID);#,'%','',strtoupper($table),'%');
  334. break;
  335. case 'db2':
  336. $colname = "%";
  337. $qid = odbc_columns($this->_connectionID, "", $schema, $table, $colname);
  338. break;
  339. default:
  340. $qid = @odbc_columns($this->_connectionID,'%','%',strtoupper($table),'%');
  341. if (empty($qid)) $qid = odbc_columns($this->_connectionID);
  342. break;
  343. }
  344. if (empty($qid)) return false;
  345. $rs = new ADORecordSet_odbc($qid);
  346. $ADODB_FETCH_MODE = $savem;
  347. if (!$rs) return false;
  348. $rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change;
  349. $rs->_fetch();
  350. $retarr = array();
  351. /*
  352. $rs->fields indices
  353. 0 TABLE_QUALIFIER
  354. 1 TABLE_SCHEM
  355. 2 TABLE_NAME
  356. 3 COLUMN_NAME
  357. 4 DATA_TYPE
  358. 5 TYPE_NAME
  359. 6 PRECISION
  360. 7 LENGTH
  361. 8 SCALE
  362. 9 RADIX
  363. 10 NULLABLE
  364. 11 REMARKS
  365. */
  366. while (!$rs->EOF) {
  367. //adodb_pr($rs->fields);
  368. if (strtoupper($rs->fields[2]) == $table && (!$schema || strtoupper($rs->fields[1]) == $schema)) {
  369. $fld = new ADOFieldObject();
  370. $fld->name = $rs->fields[3];
  371. $fld->type = $this->ODBCTypes($rs->fields[4]);
  372. // ref: http://msdn.microsoft.com/library/default.asp?url=/archive/en-us/dnaraccgen/html/msdn_odk.asp
  373. // access uses precision to store length for char/varchar
  374. if ($fld->type == 'C' or $fld->type == 'X') {
  375. if ($this->databaseType == 'access')
  376. $fld->max_length = $rs->fields[6];
  377. else if ($rs->fields[4] <= -95) // UNICODE
  378. $fld->max_length = $rs->fields[7]/2;
  379. else
  380. $fld->max_length = $rs->fields[7];
  381. } else
  382. $fld->max_length = $rs->fields[7];
  383. $fld->not_null = !empty($rs->fields[10]);
  384. $fld->scale = $rs->fields[8];
  385. $retarr[strtoupper($fld->name)] = $fld;
  386. } else if (sizeof($retarr)>0)
  387. break;
  388. $rs->MoveNext();
  389. }
  390. $rs->Close(); //-- crashes 4.03pl1 -- why?
  391. return $retarr;
  392. }
  393. function Prepare($sql)
  394. {
  395. if (! $this->_bindInputArray) return $sql; // no binding
  396. $stmt = odbc_prepare($this->_connectionID,$sql);
  397. if (!$stmt) {
  398. // we don't know whether odbc driver is parsing prepared stmts, so just return sql
  399. return $sql;
  400. }
  401. return array($sql,$stmt,false);
  402. }
  403. /* returns queryID or false */
  404. function _query($sql,$inputarr=false)
  405. {
  406. GLOBAL $php_errormsg;
  407. if (isset($php_errormsg)) $php_errormsg = '';
  408. $this->_error = '';
  409. if ($inputarr) {
  410. if (is_array($sql)) {
  411. $stmtid = $sql[1];
  412. } else {
  413. $stmtid = odbc_prepare($this->_connectionID,$sql);
  414. if ($stmtid == false) {
  415. $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
  416. return false;
  417. }
  418. }
  419. if (! odbc_execute($stmtid,$inputarr)) {
  420. //@odbc_free_result($stmtid);
  421. if ($this->_haserrorfunctions) {
  422. $this->_errorMsg = odbc_errormsg();
  423. $this->_errorCode = odbc_error();
  424. }
  425. return false;
  426. }
  427. } else if (is_array($sql)) {
  428. $stmtid = $sql[1];
  429. if (!odbc_execute($stmtid)) {
  430. //@odbc_free_result($stmtid);
  431. if ($this->_haserrorfunctions) {
  432. $this->_errorMsg = odbc_errormsg();
  433. $this->_errorCode = odbc_error();
  434. }
  435. return false;
  436. }
  437. } else
  438. $stmtid = odbc_exec($this->_connectionID,$sql);
  439. $this->_lastAffectedRows = 0;
  440. if ($stmtid) {
  441. if (@odbc_num_fields($stmtid) == 0) {
  442. $this->_lastAffectedRows = odbc_num_rows($stmtid);
  443. $stmtid = true;
  444. } else {
  445. $this->_lastAffectedRows = 0;
  446. odbc_binmode($stmtid,$this->binmode);
  447. odbc_longreadlen($stmtid,$this->maxblobsize);
  448. }
  449. if ($this->_haserrorfunctions) {
  450. $this->_errorMsg = '';
  451. $this->_errorCode = 0;
  452. } else
  453. $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
  454. } else {
  455. if ($this->_haserrorfunctions) {
  456. $this->_errorMsg = odbc_errormsg();
  457. $this->_errorCode = odbc_error();
  458. } else
  459. $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : '';
  460. }
  461. return $stmtid;
  462. }
  463. /*
  464. Insert a null into the blob field of the table first.
  465. Then use UpdateBlob to store the blob.
  466. Usage:
  467. $conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)');
  468. $conn->UpdateBlob('blobtable','blobcol',$blob,'id=1');
  469. */
  470. function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB')
  471. {
  472. return $this->Execute("UPDATE $table SET $column=? WHERE $where",array($val)) != false;
  473. }
  474. // returns true or false
  475. function _close()
  476. {
  477. $ret = @odbc_close($this->_connectionID);
  478. $this->_connectionID = false;
  479. return $ret;
  480. }
  481. function _affectedrows()
  482. {
  483. return $this->_lastAffectedRows;
  484. }
  485. }
  486. /*--------------------------------------------------------------------------------------
  487. Class Name: Recordset
  488. --------------------------------------------------------------------------------------*/
  489. class ADORecordSet_odbc extends ADORecordSet {
  490. var $bind = false;
  491. var $databaseType = "odbc";
  492. var $dataProvider = "odbc";
  493. var $useFetchArray;
  494. var $_has_stupid_odbc_fetch_api_change;
  495. function ADORecordSet_odbc($id,$mode=false)
  496. {
  497. if ($mode === false) {
  498. global $ADODB_FETCH_MODE;
  499. $mode = $ADODB_FETCH_MODE;
  500. }
  501. $this->fetchMode = $mode;
  502. $this->_queryID = $id;
  503. // the following is required for mysql odbc driver in 4.3.1 -- why?
  504. $this->EOF = false;
  505. $this->_currentRow = -1;
  506. //$this->ADORecordSet($id);
  507. }
  508. // returns the field object
  509. function &FetchField($fieldOffset = -1)
  510. {
  511. $off=$fieldOffset+1; // offsets begin at 1
  512. $o= new ADOFieldObject();
  513. $o->name = @odbc_field_name($this->_queryID,$off);
  514. $o->type = @odbc_field_type($this->_queryID,$off);
  515. $o->max_length = @odbc_field_len($this->_queryID,$off);
  516. if (ADODB_ASSOC_CASE == 0) $o->name = strtolower($o->name);
  517. else if (ADODB_ASSOC_CASE == 1) $o->name = strtoupper($o->name);
  518. return $o;
  519. }
  520. /* Use associative array to get fields array */
  521. function Fields($colname)
  522. {
  523. if ($this->fetchMode & ADODB_FETCH_ASSOC) return $this->fields[$colname];
  524. if (!$this->bind) {
  525. $this->bind = array();
  526. for ($i=0; $i < $this->_numOfFields; $i++) {
  527. $o = $this->FetchField($i);
  528. $this->bind[strtoupper($o->name)] = $i;
  529. }
  530. }
  531. return $this->fields[$this->bind[strtoupper($colname)]];
  532. }
  533. function _initrs()
  534. {
  535. global $ADODB_COUNTRECS;
  536. $this->_numOfRows = ($ADODB_COUNTRECS) ? @odbc_num_rows($this->_queryID) : -1;
  537. $this->_numOfFields = @odbc_num_fields($this->_queryID);
  538. // some silly drivers such as db2 as/400 and intersystems cache return _numOfRows = 0
  539. if ($this->_numOfRows == 0) $this->_numOfRows = -1;
  540. //$this->useFetchArray = $this->connection->useFetchArray;
  541. $this->_has_stupid_odbc_fetch_api_change = ADODB_PHPVER >= 0x4200;
  542. }
  543. function _seek($row)
  544. {
  545. return false;
  546. }
  547. // speed up SelectLimit() by switching to ADODB_FETCH_NUM as ADODB_FETCH_ASSOC is emulated
  548. function &GetArrayLimit($nrows,$offset=-1)
  549. {
  550. if ($offset <= 0) {
  551. $rs =& $this->GetArray($nrows);
  552. return $rs;
  553. }
  554. $savem = $this->fetchMode;
  555. $this->fetchMode = ADODB_FETCH_NUM;
  556. $this->Move($offset);
  557. $this->fetchMode = $savem;
  558. if ($this->fetchMode & ADODB_FETCH_ASSOC) {
  559. $this->fields =& $this->GetRowAssoc(ADODB_ASSOC_CASE);
  560. }
  561. $results = array();
  562. $cnt = 0;
  563. while (!$this->EOF && $nrows != $cnt) {
  564. $results[$cnt++] = $this->fields;
  565. $this->MoveNext();
  566. }
  567. return $results;
  568. }
  569. function MoveNext()
  570. {
  571. if ($this->_numOfRows != 0 && !$this->EOF) {
  572. $this->_currentRow++;
  573. $row = 0;
  574. if ($this->_has_stupid_odbc_fetch_api_change)
  575. $rez = @odbc_fetch_into($this->_queryID,$this->fields);
  576. else
  577. $rez = @odbc_fetch_into($this->_queryID,$row,$this->fields);
  578. if ($rez) {
  579. if ($this->fetchMode & ADODB_FETCH_ASSOC) {
  580. $this->fields =& $this->GetRowAssoc(ADODB_ASSOC_CASE);
  581. }
  582. return true;
  583. }
  584. }
  585. $this->fields = false;
  586. $this->EOF = true;
  587. return false;
  588. }
  589. function _fetch()
  590. {
  591. $row = 0;
  592. if ($this->_has_stupid_odbc_fetch_api_change)
  593. $rez = @odbc_fetch_into($this->_queryID,$this->fields,$row);
  594. else
  595. $rez = @odbc_fetch_into($this->_queryID,$row,$this->fields);
  596. if ($rez) {
  597. if ($this->fetchMode & ADODB_FETCH_ASSOC) {
  598. $this->fields =& $this->GetRowAssoc(ADODB_ASSOC_CASE);
  599. }
  600. return true;
  601. }
  602. $this->fields = false;
  603. return false;
  604. }
  605. function _close()
  606. {
  607. return @odbc_free_result($this->_queryID);
  608. }
  609. }
  610. ?>