PageRenderTime 54ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/vendor/pear/DB/common.php

http://akelosframework.googlecode.com/
PHP | 953 lines | 485 code | 138 blank | 330 comment | 89 complexity | 96d7488c07248b1138c5c6b34dcc43ad MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. //
  3. // +----------------------------------------------------------------------+
  4. // | PHP version 4.0 |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2001 The PHP Group |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 2.02 of the PHP license, |
  9. // | that is bundled with this package in the file LICENSE, and is |
  10. // | available at through the world-wide-web at |
  11. // | http://www.php.net/license/2_02.txt. |
  12. // | If you did not receive a copy of the PHP license and are unable to |
  13. // | obtain it through the world-wide-web, please send a note to |
  14. // | license@php.net so we can mail you a copy immediately. |
  15. // +----------------------------------------------------------------------+
  16. // | Authors: Stig Bakken <ssb@fast.no> |
  17. // | |
  18. // +----------------------------------------------------------------------+
  19. //
  20. // $Id: common.php,v 1.59.2.3 2001/11/13 01:26:42 ssb Exp $
  21. //
  22. // Base class for DB implementations.
  23. //
  24. /**
  25. * DB_common is a base class for DB implementations, and must be
  26. * inherited by all such.
  27. */
  28. class DB_common extends PEAR
  29. {
  30. // {{{ properties
  31. var $features; // assoc of capabilities for this DB implementation
  32. var $errorcode_map; // assoc mapping native error codes to DB ones
  33. var $type; // DB type (mysql, oci8, odbc etc.)
  34. var $prepare_tokens;
  35. var $prepare_types;
  36. var $prepared_queries;
  37. var $prepare_maxstmt = 0;
  38. var $last_query = '';
  39. var $fetchmode = DB_FETCHMODE_ORDERED;
  40. var $fetchmode_object_class = 'stdClass';
  41. var $limit_from = null; // for limit queries, the row to start fetching
  42. var $limit_count = null; // for limit queries, the number of rows to fetch
  43. var $options = array(
  44. 'persistent' => false, // persistent connection?
  45. 'optimize' => 'performance', // 'performance' or 'portability'
  46. 'debug' => 0 // numeric debug level
  47. );
  48. /*
  49. var $features['limit'] => 'emulate' // 'emulate' => emulate with fetch row by number
  50. // 'alter' => alter the query
  51. // false => no support for limit queries
  52. */
  53. var $dbh;
  54. // }}}
  55. // {{{ toString()
  56. function toString()
  57. {
  58. $info = get_class($this);
  59. $info .= ": (phptype=" . $this->phptype .
  60. ", dbsyntax=" . $this->dbsyntax .
  61. ")";
  62. if ($this->connection) {
  63. $info .= " [connected]";
  64. }
  65. return $info;
  66. }
  67. // }}}
  68. // {{{ constructor
  69. function DB_common()
  70. {
  71. $this->PEAR('DB_Error');
  72. $this->features = array();
  73. $this->errorcode_map = array();
  74. $this->fetchmode = DB_FETCHMODE_ORDERED;
  75. }
  76. // }}}
  77. // {{{ quoteString()
  78. /**
  79. * Quotes a string so it can be safely used within string delimiters
  80. * in a query (preserved for compatibility issues, quote() is prefered).
  81. *
  82. * @see quote()
  83. */
  84. function quoteString($string)
  85. {
  86. $string = $this->quote($string);
  87. if ($string{0} == "'") {
  88. return substr($string, 1, -1);
  89. }
  90. return $string;
  91. }
  92. /**
  93. * Quotes a string so it can be safely used in a query. It will return
  94. * the string with single quotes around. Other backend quote styles
  95. * should override this method.
  96. *
  97. * @param $string the input string to quote
  98. *
  99. * @return string The NULL string or the string quotes
  100. * in magic_quote_sybase style
  101. */
  102. function quote($string)
  103. {
  104. return ($string === null) ? 'NULL' : "'".str_replace("'", "''", $string)."'";
  105. }
  106. // }}}
  107. // {{{ provides()
  108. /**
  109. * Tell whether a DB implementation or its backend extension
  110. * supports a given feature.
  111. *
  112. * @param $feature name of the feature (see the DB class doc)
  113. *
  114. * @return bool whether this DB implementation supports $feature
  115. */
  116. function provides($feature)
  117. {
  118. return $this->features[$feature];
  119. }
  120. // }}}
  121. // {{{ errorCode()
  122. /**
  123. * Map native error codes to DB's portable ones. Requires that
  124. * the DB implementation's constructor fills in the $errorcode_map
  125. * property.
  126. *
  127. * @param $nativecode the native error code, as returned by the backend
  128. * database extension (string or integer)
  129. *
  130. * @return int a portable DB error code, or FALSE if this DB
  131. * implementation has no mapping for the given error code.
  132. */
  133. function errorCode($nativecode)
  134. {
  135. if (isset($this->errorcode_map[$nativecode])) {
  136. return $this->errorcode_map[$nativecode];
  137. }
  138. //php_error(E_WARNING, get_class($this)."::errorCode: no mapping for $nativecode");
  139. // Fall back to DB_ERROR if there was no mapping.
  140. return DB_ERROR;
  141. }
  142. // }}}
  143. // {{{ errorMessage()
  144. /**
  145. * Map a DB error code to a textual message. This is actually
  146. * just a wrapper for DB::errorMessage().
  147. *
  148. * @param $dbcode the DB error code
  149. *
  150. * @return string the corresponding error message, of FALSE
  151. * if the error code was unknown
  152. */
  153. function errorMessage($dbcode)
  154. {
  155. return DB::errorMessage($this->errorcode_map[$dbcode]);
  156. }
  157. // }}}
  158. // {{{ raiseError()
  159. /**
  160. * This method is used to communicate an error and invoke error
  161. * callbacks etc. Basically a wrapper for PEAR::raiseError
  162. * without the message string.
  163. *
  164. * @param mixed integer error code, or a PEAR error object (all
  165. * other parameters are ignored if this parameter is
  166. * an object
  167. *
  168. * @param int error mode, see PEAR_Error docs
  169. *
  170. * @param mixed If error mode is PEAR_ERROR_TRIGGER, this is the
  171. * error level (E_USER_NOTICE etc). If error mode is
  172. * PEAR_ERROR_CALLBACK, this is the callback function,
  173. * either as a function name, or as an array of an
  174. * object and method name. For other error modes this
  175. * parameter is ignored.
  176. *
  177. * @param string Extra debug information. Defaults to the last
  178. * query and native error code.
  179. *
  180. * @param mixed Native error code, integer or string depending the
  181. * backend.
  182. *
  183. * @return object a PEAR error object
  184. *
  185. * @see PEAR_Error
  186. */
  187. function &raiseError($code = DB_ERROR, $mode = null, $options = null,
  188. $userinfo = null, $nativecode = null)
  189. {
  190. // The error is yet a DB error object
  191. if (is_object($code)) {
  192. return PEAR::raiseError($code, null, null, null, null, null, true);
  193. }
  194. if ($userinfo === null) {
  195. $userinfo = $this->last_query;
  196. }
  197. if ($nativecode) {
  198. $userinfo .= " [nativecode=$nativecode]";
  199. }
  200. return PEAR::raiseError(null, $code, $mode, $options, $userinfo,
  201. 'DB_Error', true);
  202. }
  203. // }}}
  204. // {{{ setFetchMode()
  205. /**
  206. * Sets which fetch mode should be used by default on queries
  207. * on this connection.
  208. *
  209. * @param $fetchmode int DB_FETCHMODE_ORDERED or
  210. * DB_FETCHMODE_ASSOC, possibly bit-wise OR'ed with
  211. * DB_FETCHMODE_FLIPPED.
  212. *
  213. * @param $object_class string optional The class of the object
  214. * to be returned by the fetch methods when
  215. * the DB_FETCHMODE_OBJECT mode is selected.
  216. * If no class is specified by default a cast
  217. * to object from the assoc array row will be done.
  218. * There is also the posibility to use and extend the
  219. * 'DB_Row' class.
  220. *
  221. * @see DB_FETCHMODE_ORDERED
  222. * @see DB_FETCHMODE_ASSOC
  223. * @see DB_FETCHMODE_FLIPPED
  224. * @see DB_FETCHMODE_OBJECT
  225. * @see DB_Row::DB_Row()
  226. */
  227. function setFetchMode($fetchmode, $object_class = null)
  228. {
  229. switch ($fetchmode) {
  230. case DB_FETCHMODE_OBJECT:
  231. if ($object_class) {
  232. $this->fetchmode_object_class = $object_class;
  233. }
  234. case DB_FETCHMODE_ORDERED:
  235. case DB_FETCHMODE_ASSOC:
  236. $this->fetchmode = $fetchmode;
  237. break;
  238. default:
  239. return $this->raiseError('invalid fetchmode mode');
  240. }
  241. }
  242. // }}}
  243. // {{{ setOption()
  244. function setOption($option, $value)
  245. {
  246. if (isset($this->options[$option])) {
  247. $this->options[$option] = $value;
  248. return DB_OK;
  249. }
  250. return $this->raiseError("unknown option $option");
  251. }
  252. // }}}
  253. // {{{ getOption()
  254. function getOption($option)
  255. {
  256. if (isset($this->options[$option])) {
  257. return $this->options[$option];
  258. }
  259. return $this->raiseError("unknown option $option");
  260. }
  261. // }}}
  262. // {{{ prepare()
  263. /**
  264. * Prepares a query for multiple execution with execute(). With
  265. * some database backends, this is emulated.
  266. */
  267. function prepare($query)
  268. {
  269. $tokens = split("[\&\?\!]", $query);
  270. $token = 0;
  271. $types = array();
  272. for ($i = 0; $i < strlen($query); $i++) {
  273. switch ($query[$i]) {
  274. case '?':
  275. $types[$token++] = DB_PARAM_SCALAR;
  276. break;
  277. case '&':
  278. $types[$token++] = DB_PARAM_OPAQUE;
  279. break;
  280. case '!':
  281. $types[$token++] = DB_PARAM_MISC;
  282. break;
  283. }
  284. }
  285. $this->prepare_tokens[] = &$tokens;
  286. end($this->prepare_tokens);
  287. $k = key($this->prepare_tokens);
  288. $this->prepare_types[$k] = $types;
  289. $this->prepared_queries[$k] = &$query;
  290. return $k;
  291. }
  292. // }}}
  293. // {{{ execute()
  294. function execute($stmt, $data = false)
  295. {
  296. $realquery = $this->executeEmulateQuery($stmt, $data);
  297. if (DB::isError($realquery)) {
  298. return $realquery;
  299. }
  300. $result = $this->simpleQuery($realquery);
  301. if (DB::isError($result) || $result === DB_OK) {
  302. return $result;
  303. } else {
  304. return new DB_result($this, $result);
  305. }
  306. }
  307. // }}}
  308. // {{{ executeEmulateQuery()
  309. /**
  310. * @return a string containing the real query run when emulating
  311. * prepare/execute. A DB error code is returned on failure.
  312. */
  313. function executeEmulateQuery($stmt, $data = false)
  314. {
  315. $p = &$this->prepare_tokens;
  316. if (!isset($this->prepare_tokens[$stmt]) ||
  317. !is_array($this->prepare_tokens[$stmt]) ||
  318. !sizeof($this->prepare_tokens[$stmt]))
  319. {
  320. return $this->raiseError(DB_ERROR_INVALID);
  321. }
  322. $qq = &$this->prepare_tokens[$stmt];
  323. $qp = sizeof($qq) - 1;
  324. if ((!$data && $qp > 0) ||
  325. (!is_array($data) && $qp > 1) ||
  326. (is_array($data) && $qp > sizeof($data)))
  327. {
  328. $this->last_query = $this->prepared_queries[$stmt];
  329. return $this->raiseError(DB_ERROR_NEED_MORE_DATA);
  330. }
  331. $realquery = $qq[0];
  332. for ($i = 0; $i < $qp; $i++) {
  333. $type = $this->prepare_types[$stmt][$i];
  334. if ($type == DB_PARAM_OPAQUE) {
  335. if (is_array($data)) {
  336. $fp = fopen($data[$i], 'r');
  337. } else {
  338. $fp = fopen($data, 'r');
  339. }
  340. $pdata = '';
  341. if ($fp) {
  342. while (($buf = fread($fp, 4096)) != false) {
  343. $pdata .= $buf;
  344. }
  345. }
  346. } else {
  347. if (is_array($data)) {
  348. $pdata = &$data[$i];
  349. } else {
  350. $pdata = &$data;
  351. }
  352. }
  353. $realquery .= ($type != DB_PARAM_MISC) ? $this->quote($pdata) : $pdata;
  354. $realquery .= $qq[$i + 1];
  355. }
  356. return $realquery;
  357. }
  358. // }}}
  359. // {{{ executeMultiple()
  360. /**
  361. * This function does several execute() calls on the same
  362. * statement handle. $data must be an array indexed numerically
  363. * from 0, one execute call is done for every "row" in the array.
  364. *
  365. * If an error occurs during execute(), executeMultiple() does not
  366. * execute the unfinished rows, but rather returns that error.
  367. */
  368. function executeMultiple( $stmt, &$data )
  369. {
  370. for($i = 0; $i < sizeof( $data ); $i++) {
  371. $res = $this->execute($stmt, $data[$i]);
  372. if (DB::isError($res)) {
  373. return $res;
  374. }
  375. }
  376. return DB_OK;
  377. }
  378. // }}}
  379. // {{{ modifyQuery()
  380. /**
  381. * This method is used by backends to alter queries for various
  382. * reasons. It is defined here to assure that all implementations
  383. * have this method defined.
  384. *
  385. * @access private
  386. *
  387. * @param query to modify
  388. *
  389. * @return the new (modified) query
  390. */
  391. function modifyQuery($query) {
  392. return $query;
  393. }
  394. // }}}
  395. // {{{ modifyLimitQuery()
  396. function modifyLimitQuery($query, $from, $count)
  397. {
  398. return $query;
  399. }
  400. // }}}
  401. // {{{ query()
  402. /**
  403. * Send a query to the database and return any results with a
  404. * DB_result object.
  405. *
  406. * @access public
  407. *
  408. * @param the SQL query
  409. *
  410. * @return object a DB_result object or DB_OK on success, a DB
  411. * error on failure
  412. *
  413. * @see DB::isError
  414. */
  415. function &query($query) {
  416. $result = $this->simpleQuery($query);
  417. if (DB::isError($result) || $result === DB_OK) {
  418. return $result;
  419. } else {
  420. return new DB_result($this, $result);
  421. }
  422. }
  423. // }}}
  424. // {{{ limitQuery()
  425. function limitQuery($query, $from, $count)
  426. {
  427. $query = $this->modifyLimitQuery($query, $from, $count);
  428. $result = $this->simpleQuery($query);
  429. if (DB::isError($result) || $result === DB_OK) {
  430. return $result;
  431. } else {
  432. $this->limit_from = $from;
  433. $this->limit_count = $count;
  434. return new DB_result($this, $result);
  435. }
  436. }
  437. // }}}
  438. // {{{ getOne()
  439. /**
  440. * Fetch the first column of the first row of data returned from
  441. * a query. Takes care of doing the query and freeing the results
  442. * when finished.
  443. *
  444. * @param $query the SQL query
  445. * @param $params if supplied, prepare/execute will be used
  446. * with this array as execute parameters
  447. * @access public
  448. */
  449. function &getOne($query, $params = array())
  450. {
  451. settype($params, "array");
  452. if (sizeof($params) > 0) {
  453. $sth = $this->prepare($query);
  454. if (DB::isError($sth)) {
  455. return $sth;
  456. }
  457. $res = $this->execute($sth, $params);
  458. } else {
  459. $res = $this->query($query);
  460. }
  461. if (DB::isError($res)) {
  462. return $res;
  463. }
  464. $err = $res->fetchInto($row, DB_FETCHMODE_ORDERED);
  465. if ($err !== DB_OK) {
  466. return $err;
  467. }
  468. $res->free();
  469. if (isset($sth)) {
  470. $this->freeResult($sth);
  471. }
  472. return $row[0];
  473. }
  474. // }}}
  475. // {{{ getRow()
  476. /**
  477. * Fetch the first row of data returned from a query. Takes care
  478. * of doing the query and freeing the results when finished.
  479. *
  480. * @param $query the SQL query
  481. * @param $fetchmode the fetch mode to use
  482. * @param $params array if supplied, prepare/execute will be used
  483. * with this array as execute parameters
  484. * @access public
  485. * @return array the first row of results as an array indexed from
  486. * 0, or a DB error code.
  487. */
  488. function &getRow($query,
  489. $params = null,
  490. $fetchmode = DB_FETCHMODE_DEFAULT)
  491. {
  492. // compat check, the params and fetchmode parameters used to
  493. // have the opposite order
  494. if (!is_array($params)) {
  495. if (is_array($fetchmode)) {
  496. $tmp = $params;
  497. $params = $fetchmode;
  498. $fetchmode = $tmp;
  499. } elseif ($params !== null) {
  500. $fetchmode = $params;
  501. $params = null;
  502. }
  503. }
  504. $params = (empty($params)) ? array() : $params;
  505. $fetchmode = (empty($fetchmode)) ? DB_FETCHMODE_DEFAULT : $fetchmode;
  506. settype($params, 'array');
  507. if (sizeof($params) > 0) {
  508. $sth = $this->prepare($query);
  509. if (DB::isError($sth)) {
  510. return $sth;
  511. }
  512. $res = $this->execute($sth, $params);
  513. } else {
  514. $res = $this->query($query);
  515. }
  516. if (DB::isError($res)) {
  517. return $res;
  518. }
  519. $err = $res->fetchInto($row, $fetchmode);
  520. if ($err !== DB_OK) {
  521. return $err;
  522. }
  523. $res->free();
  524. if (isset($sth)) {
  525. $this->freeResult($sth);
  526. }
  527. return $row;
  528. }
  529. // }}}
  530. // {{{ getCol()
  531. /**
  532. * Fetch a single column from a result set and return it as an
  533. * indexed array.
  534. *
  535. * @param $query the SQL query
  536. *
  537. * @param $col which column to return (integer [column number,
  538. * starting at 0] or string [column name])
  539. *
  540. * @param $params array if supplied, prepare/execute will be used
  541. * with this array as execute parameters
  542. * @access public
  543. *
  544. * @return array an indexed array with the data from the first
  545. * row at index 0, or a DB error code.
  546. */
  547. function &getCol($query, $col = 0, $params = array())
  548. {
  549. settype($params, "array");
  550. if (sizeof($params) > 0) {
  551. $sth = $this->prepare($query);
  552. if (DB::isError($sth)) {
  553. return $sth;
  554. }
  555. $res = $this->execute($sth, $params);
  556. } else {
  557. $res = $this->query($query);
  558. }
  559. if (DB::isError($res)) {
  560. return $res;
  561. }
  562. $fetchmode = is_int($col) ? DB_FETCHMODE_ORDERED : DB_FETCHMODE_ASSOC;
  563. $ret = array();
  564. while (is_array($row = $res->fetchRow($fetchmode))) {
  565. $ret[] = $row[$col];
  566. }
  567. if (DB::isError($row)) {
  568. $ret = $row;
  569. }
  570. $res->free();
  571. if (isset($sth)) {
  572. $this->freeResult($sth);
  573. }
  574. return $ret;
  575. }
  576. // }}}
  577. // {{{ getAssoc()
  578. /**
  579. * Fetch the entire result set of a query and return it as an
  580. * associative array using the first column as the key.
  581. *
  582. * @param $query the SQL query
  583. *
  584. * @param $force_array (optional) used only when the query returns
  585. * exactly two columns. If true, the values of the returned array
  586. * will be one-element arrays instead of scalars.
  587. *
  588. * @access public
  589. *
  590. * @return array associative array with results from the query.
  591. * If the result set contains more than two columns, the value
  592. * will be an array of the values from column 2-n. If the result
  593. * set contains only two columns, the returned value will be a
  594. * scalar with the value of the second column (unless forced to an
  595. * array with the $force_array parameter). A DB error code is
  596. * returned on errors. If the result set contains fewer than two
  597. * columns, a DB_ERROR_TRUNCATED error is returned.
  598. *
  599. * For example, if the table "mytable" contains:
  600. *
  601. * ID TEXT DATE
  602. * --------------------------------
  603. * 1 'one' 944679408
  604. * 2 'two' 944679408
  605. * 3 'three' 944679408
  606. *
  607. * Then the call getAssoc('SELECT id,text FROM mytable') returns:
  608. * array(
  609. * '1' => 'one',
  610. * '2' => 'two',
  611. * '3' => 'three',
  612. * )
  613. *
  614. * ...while the call getAssoc('SELECT id,text,date FROM mytable') returns:
  615. * array(
  616. * '1' => array('one', '944679408'),
  617. * '2' => array('two', '944679408'),
  618. * '3' => array('three', '944679408')
  619. * )
  620. *
  621. * Keep in mind that database functions in PHP usually return string
  622. * values for results regardless of the database's internal type.
  623. */
  624. function &getAssoc($query, $force_array = false, $params = array())
  625. {
  626. settype($params, "array");
  627. if (sizeof($params) > 0) {
  628. $sth = $this->prepare($query);
  629. if (DB::isError($sth)) {
  630. return $sth;
  631. }
  632. $res = $this->execute($sth, $params);
  633. } else {
  634. $res = $this->query($query);
  635. }
  636. if (DB::isError($res)) {
  637. return $res;
  638. }
  639. $cols = $res->numCols();
  640. if ($cols < 2) {
  641. return $this->raiseError(DB_ERROR_TRUNCATED);
  642. }
  643. $results = array();
  644. if ($cols > 2 || $force_array) {
  645. // return array values
  646. // XXX this part can be optimized
  647. while (is_array($row = $res->fetchRow(DB_FETCHMODE_ORDERED))) {
  648. reset($row);
  649. // we copy the row of data into a new array
  650. // to get indices running from 0 again
  651. $results[$row[0]] = array_slice($row, 1);
  652. }
  653. if (DB::isError($row)) {
  654. $results = $row;
  655. }
  656. } else {
  657. // return scalar values
  658. while (is_array($row = $res->fetchRow(DB_FETCHMODE_ORDERED))) {
  659. $results[$row[0]] = $row[1];
  660. }
  661. if (DB::isError($row)) {
  662. $results = $row;
  663. }
  664. }
  665. $res->free();
  666. if (isset($sth)) {
  667. $this->freeResult($sth);
  668. }
  669. return $results;
  670. }
  671. // }}}
  672. // {{{ getAll()
  673. /**
  674. * Fetch all the rows returned from a query.
  675. *
  676. * @param $query the SQL query
  677. * @access public
  678. * @return array an nested array, or a DB error
  679. */
  680. function &getAll($query,
  681. $params = null,
  682. $fetchmode = DB_FETCHMODE_DEFAULT)
  683. {
  684. // compat check, the params and fetchmode parameters used to
  685. // have the opposite order
  686. if (!is_array($params)) {
  687. if (is_array($fetchmode)) {
  688. $tmp = $params;
  689. $params = $fetchmode;
  690. $fetchmode = $tmp;
  691. } elseif ($params !== null) {
  692. $fetchmode = $params;
  693. $params = null;
  694. }
  695. }
  696. $params = (empty($params)) ? array() : $params;
  697. $fetchmode = (empty($fetchmode)) ? DB_FETCHMODE_DEFAULT : $fetchmode;
  698. settype($params, "array");
  699. if (sizeof($params) > 0) {
  700. $sth = $this->prepare($query);
  701. if (DB::isError($sth)) {
  702. return $sth;
  703. }
  704. $res = $this->execute($sth, $params);
  705. } else {
  706. $res = $this->query($query);
  707. }
  708. if (DB::isError($res)) {
  709. return $res;
  710. }
  711. $results = array();
  712. $this->pushErrorHandling(PEAR_ERROR_RETURN);
  713. while (DB_OK === $res->fetchInto($row, $fetchmode)) {
  714. if ($fetchmode & DB_FETCHMODE_FLIPPED) {
  715. foreach ($row as $key => $val) {
  716. $results[$key][] = $val;
  717. }
  718. } else {
  719. $results[] = $row;
  720. }
  721. }
  722. $this->popErrorHandling();
  723. $res->free();
  724. if (isset($sth)) {
  725. $this->freeResult($sth);
  726. }
  727. if (DB::isError($row)) {
  728. return $this->raiseError($row);
  729. }
  730. return $results;
  731. }
  732. // }}}
  733. // {{{ autoCommit()
  734. function autoCommit($onoff=false)
  735. {
  736. return $this->raiseError(DB_ERROR_NOT_CAPABLE);
  737. }
  738. // }}}
  739. // {{{ commit()
  740. function commit()
  741. {
  742. return $this->raiseError(DB_ERROR_NOT_CAPABLE);
  743. }
  744. // }}}
  745. // {{{ rollback()
  746. function rollback()
  747. {
  748. return $this->raiseError(DB_ERROR_NOT_CAPABLE);
  749. }
  750. // }}}
  751. // {{{ numRows()
  752. function numRows($result)
  753. {
  754. return $this->raiseError(DB_ERROR_NOT_CAPABLE);
  755. }
  756. // }}}
  757. // {{{ affectedRows()
  758. function affectedRows()
  759. {
  760. return $this->raiseError(DB_ERROR_NOT_CAPABLE);
  761. }
  762. // }}}
  763. // {{{ errorNative()
  764. function errorNative()
  765. {
  766. return $this->raiseError(DB_ERROR_NOT_CAPABLE);
  767. }
  768. // }}}
  769. // {{{ nextId()
  770. function nextId($seq_name, $ondemand = true)
  771. {
  772. return $this->raiseError(DB_ERROR_NOT_CAPABLE);
  773. }
  774. // }}}
  775. // {{{ createSequence()
  776. function createSequence($seq_name)
  777. {
  778. return $this->raiseError(DB_ERROR_NOT_CAPABLE);
  779. }
  780. // }}}
  781. // {{{ dropSequence()
  782. function dropSequence($seq_name)
  783. {
  784. return $this->raiseError(DB_ERROR_NOT_CAPABLE);
  785. }
  786. // }}}
  787. // {{{ tableInfo()
  788. function tableInfo($result, $mode = null)
  789. {
  790. return $this->raiseError(DB_ERROR_NOT_CAPABLE);
  791. }
  792. // }}}
  793. // {{{ getTables()
  794. function getTables()
  795. {
  796. return $this->getListOf('tables');
  797. }
  798. // }}}
  799. // {{{ getListOf()
  800. function getListOf($type)
  801. {
  802. $sql = $this->getSpecialQuery($type);
  803. if ($sql === null) { // No support
  804. return $this->raiseError(DB_ERROR_UNSUPPORTED);
  805. } elseif (is_int($sql) || DB::isError($sql)) { // Previous error
  806. return $this->raiseError($sql);
  807. } elseif (is_array($sql)) { // Already the result
  808. return $sql;
  809. }
  810. return $this->getCol($sql); // Launch this query
  811. }
  812. // }}}
  813. }
  814. ?>