Automatically exported from code.google.com/p/planningalerts
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 
 

806 rader
29 KiB

  1. <?php
  2. // +----------------------------------------------------------------------+
  3. // | PHP versions 4 and 5 |
  4. // +----------------------------------------------------------------------+
  5. // | Copyright (c) 1998-2006 Manuel Lemos, Tomas V.V.Cox, |
  6. // | Stig. S. Bakken, Lukas Smith |
  7. // | All rights reserved. |
  8. // +----------------------------------------------------------------------+
  9. // | MDB2 is a merge of PEAR DB and Metabases that provides a unified DB |
  10. // | API as well as database abstraction for PHP applications. |
  11. // | This LICENSE is in the BSD license style. |
  12. // | |
  13. // | Redistribution and use in source and binary forms, with or without |
  14. // | modification, are permitted provided that the following conditions |
  15. // | are met: |
  16. // | |
  17. // | Redistributions of source code must retain the above copyright |
  18. // | notice, this list of conditions and the following disclaimer. |
  19. // | |
  20. // | Redistributions in binary form must reproduce the above copyright |
  21. // | notice, this list of conditions and the following disclaimer in the |
  22. // | documentation and/or other materials provided with the distribution. |
  23. // | |
  24. // | Neither the name of Manuel Lemos, Tomas V.V.Cox, Stig. S. Bakken, |
  25. // | Lukas Smith nor the names of his contributors may be used to endorse |
  26. // | or promote products derived from this software without specific prior|
  27. // | written permission. |
  28. // | |
  29. // | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
  30. // | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
  31. // | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
  32. // | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
  33. // | REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
  34. // | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
  35. // | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS|
  36. // | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
  37. // | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
  38. // | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY|
  39. // | WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
  40. // | POSSIBILITY OF SUCH DAMAGE. |
  41. // +----------------------------------------------------------------------+
  42. // | Author: Lukas Smith <smith@pooteeweet.org> |
  43. // +----------------------------------------------------------------------+
  44. //
  45. // $Id: Common.php,v 1.56 2006/08/21 16:18:10 nrf Exp $
  46. //
  47. /**
  48. * @package MDB2
  49. * @category Database
  50. * @author Lukas Smith <smith@pooteeweet.org>
  51. */
  52. /**
  53. * Base class for the management modules that is extended by each MDB2 driver
  54. *
  55. * @package MDB2
  56. * @category Database
  57. * @author Lukas Smith <smith@pooteeweet.org>
  58. */
  59. class MDB2_Driver_Manager_Common extends MDB2_Module_Common
  60. {
  61. // }}}
  62. // {{{ getFieldDeclarationList()
  63. /**
  64. * Get declaration of a number of field in bulk
  65. *
  66. * @param string $fields a multidimensional associative array.
  67. * The first dimension determines the field name, while the second
  68. * dimension is keyed with the name of the properties
  69. * of the field being declared as array indexes. Currently, the types
  70. * of supported field properties are as follows:
  71. *
  72. * default
  73. * Boolean value to be used as default for this field.
  74. *
  75. * notnull
  76. * Boolean flag that indicates whether this field is constrained
  77. * to not be set to null.
  78. *
  79. * @return mixed string on success, a MDB2 error on failure
  80. * @access public
  81. */
  82. function getFieldDeclarationList($fields)
  83. {
  84. $db =& $this->getDBInstance();
  85. if (PEAR::isError($db)) {
  86. return $db;
  87. }
  88. if (!is_array($fields) || empty($fields)) {
  89. return $db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null,
  90. 'missing any fields', __FUNCTION__);
  91. }
  92. foreach ($fields as $field_name => $field) {
  93. $query = $db->getDeclaration($field['type'], $field_name, $field);
  94. if (PEAR::isError($query)) {
  95. return $query;
  96. }
  97. $query_fields[] = $query;
  98. }
  99. return implode(', ', $query_fields);
  100. }
  101. // }}}
  102. // {{{ _fixSequenceName()
  103. /**
  104. * Removes any formatting in an sequence name using the 'seqname_format' option
  105. *
  106. * @param string $sqn string that containts name of a potential sequence
  107. * @param bool $check if only formatted sequences should be returned
  108. * @return string name of the sequence with possible formatting removed
  109. * @access protected
  110. */
  111. function _fixSequenceName($sqn, $check = false)
  112. {
  113. $db =& $this->getDBInstance();
  114. if (PEAR::isError($db)) {
  115. return $db;
  116. }
  117. $seq_pattern = '/^'.preg_replace('/%s/', '([a-z0-9_]+)', $db->options['seqname_format']).'$/i';
  118. $seq_name = preg_replace($seq_pattern, '\\1', $sqn);
  119. if ($seq_name && !strcasecmp($sqn, $db->getSequenceName($seq_name))) {
  120. return $seq_name;
  121. }
  122. if ($check) {
  123. return false;
  124. }
  125. return $sqn;
  126. }
  127. // }}}
  128. // {{{ _fixIndexName()
  129. /**
  130. * Removes any formatting in an index name using the 'idxname_format' option
  131. *
  132. * @param string $idx string that containts name of anl index
  133. * @return string name of the index with possible formatting removed
  134. * @access protected
  135. */
  136. function _fixIndexName($idx)
  137. {
  138. $db =& $this->getDBInstance();
  139. if (PEAR::isError($db)) {
  140. return $db;
  141. }
  142. $idx_pattern = '/^'.preg_replace('/%s/', '([a-z0-9_]+)', $db->options['idxname_format']).'$/i';
  143. $idx_name = preg_replace($idx_pattern, '\\1', $idx);
  144. if ($idx_name && !strcasecmp($idx, $db->getIndexName($idx_name))) {
  145. return $idx_name;
  146. }
  147. return $idx;
  148. }
  149. // }}}
  150. // {{{ createDatabase()
  151. /**
  152. * create a new database
  153. *
  154. * @param string $name name of the database that should be created
  155. * @return mixed MDB2_OK on success, a MDB2 error on failure
  156. * @access public
  157. */
  158. function createDatabase($database)
  159. {
  160. $db =& $this->getDBInstance();
  161. if (PEAR::isError($db)) {
  162. return $db;
  163. }
  164. return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
  165. 'method not implemented', __FUNCTION__);
  166. }
  167. // }}}
  168. // {{{ dropDatabase()
  169. /**
  170. * drop an existing database
  171. *
  172. * @param string $name name of the database that should be dropped
  173. * @return mixed MDB2_OK on success, a MDB2 error on failure
  174. * @access public
  175. */
  176. function dropDatabase($database)
  177. {
  178. $db =& $this->getDBInstance();
  179. if (PEAR::isError($db)) {
  180. return $db;
  181. }
  182. return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
  183. 'method not implemented', __FUNCTION__);
  184. }
  185. // }}}
  186. // {{{ createTable()
  187. /**
  188. * create a new table
  189. *
  190. * @param string $name Name of the database that should be created
  191. * @param array $fields Associative array that contains the definition of each field of the new table
  192. * The indexes of the array entries are the names of the fields of the table an
  193. * the array entry values are associative arrays like those that are meant to be
  194. * passed with the field definitions to get[Type]Declaration() functions.
  195. * array(
  196. * 'id' => array(
  197. * 'type' => 'integer',
  198. * 'unsigned' => 1
  199. * 'notnull' => 1
  200. * 'default' => 0
  201. * ),
  202. * 'name' => array(
  203. * 'type' => 'text',
  204. * 'length' => 12
  205. * ),
  206. * 'password' => array(
  207. * 'type' => 'text',
  208. * 'length' => 12
  209. * )
  210. * );
  211. * @param array $options An associative array of table options:
  212. *
  213. * @return mixed MDB2_OK on success, a MDB2 error on failure
  214. * @access public
  215. */
  216. function createTable($name, $fields, $options = array())
  217. {
  218. $db =& $this->getDBInstance();
  219. if (PEAR::isError($db)) {
  220. return $db;
  221. }
  222. if (!$name) {
  223. return $db->raiseError(MDB2_ERROR_CANNOT_CREATE, null, null,
  224. 'no valid table name specified', __FUNCTION__);
  225. }
  226. if (empty($fields)) {
  227. return $db->raiseError(MDB2_ERROR_CANNOT_CREATE, null, null,
  228. 'no fields specified for table "'.$name.'"', __FUNCTION__);
  229. }
  230. $query_fields = $this->getFieldDeclarationList($fields);
  231. if (PEAR::isError($query_fields)) {
  232. return $query_fields;
  233. }
  234. if (!empty($options['primary'])) {
  235. $query_fields.= ', PRIMARY KEY ('.implode(', ', array_keys($options['primary'])).')';
  236. }
  237. $name = $db->quoteIdentifier($name, true);
  238. $query = "CREATE TABLE $name ($query_fields)";
  239. return $db->exec($query);
  240. }
  241. // }}}
  242. // {{{ dropTable()
  243. /**
  244. * drop an existing table
  245. *
  246. * @param string $name name of the table that should be dropped
  247. * @return mixed MDB2_OK on success, a MDB2 error on failure
  248. * @access public
  249. */
  250. function dropTable($name)
  251. {
  252. $db =& $this->getDBInstance();
  253. if (PEAR::isError($db)) {
  254. return $db;
  255. }
  256. $name = $db->quoteIdentifier($name, true);
  257. return $db->exec("DROP TABLE $name");
  258. }
  259. // }}}
  260. // {{{ alterTable()
  261. /**
  262. * alter an existing table
  263. *
  264. * @param string $name name of the table that is intended to be changed.
  265. * @param array $changes associative array that contains the details of each type
  266. * of change that is intended to be performed. The types of
  267. * changes that are currently supported are defined as follows:
  268. *
  269. * name
  270. *
  271. * New name for the table.
  272. *
  273. * add
  274. *
  275. * Associative array with the names of fields to be added as
  276. * indexes of the array. The value of each entry of the array
  277. * should be set to another associative array with the properties
  278. * of the fields to be added. The properties of the fields should
  279. * be the same as defined by the Metabase parser.
  280. *
  281. *
  282. * remove
  283. *
  284. * Associative array with the names of fields to be removed as indexes
  285. * of the array. Currently the values assigned to each entry are ignored.
  286. * An empty array should be used for future compatibility.
  287. *
  288. * rename
  289. *
  290. * Associative array with the names of fields to be renamed as indexes
  291. * of the array. The value of each entry of the array should be set to
  292. * another associative array with the entry named name with the new
  293. * field name and the entry named Declaration that is expected to contain
  294. * the portion of the field declaration already in DBMS specific SQL code
  295. * as it is used in the CREATE TABLE statement.
  296. *
  297. * change
  298. *
  299. * Associative array with the names of the fields to be changed as indexes
  300. * of the array. Keep in mind that if it is intended to change either the
  301. * name of a field and any other properties, the change array entries
  302. * should have the new names of the fields as array indexes.
  303. *
  304. * The value of each entry of the array should be set to another associative
  305. * array with the properties of the fields to that are meant to be changed as
  306. * array entries. These entries should be assigned to the new values of the
  307. * respective properties. The properties of the fields should be the same
  308. * as defined by the Metabase parser.
  309. *
  310. * Example
  311. * array(
  312. * 'name' => 'userlist',
  313. * 'add' => array(
  314. * 'quota' => array(
  315. * 'type' => 'integer',
  316. * 'unsigned' => 1
  317. * )
  318. * ),
  319. * 'remove' => array(
  320. * 'file_limit' => array(),
  321. * 'time_limit' => array()
  322. * ),
  323. * 'change' => array(
  324. * 'name' => array(
  325. * 'length' => '20',
  326. * 'definition' => array(
  327. * 'type' => 'text',
  328. * 'length' => 20,
  329. * ),
  330. * )
  331. * ),
  332. * 'rename' => array(
  333. * 'sex' => array(
  334. * 'name' => 'gender',
  335. * 'definition' => array(
  336. * 'type' => 'text',
  337. * 'length' => 1,
  338. * 'default' => 'M',
  339. * ),
  340. * )
  341. * )
  342. * )
  343. *
  344. * @param boolean $check indicates whether the function should just check if the DBMS driver
  345. * can perform the requested table alterations if the value is true or
  346. * actually perform them otherwise.
  347. * @access public
  348. *
  349. * @return mixed MDB2_OK on success, a MDB2 error on failure
  350. */
  351. function alterTable($name, $changes, $check)
  352. {
  353. $db =& $this->getDBInstance();
  354. if (PEAR::isError($db)) {
  355. return $db;
  356. }
  357. return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
  358. 'method not implemented', __FUNCTION__);
  359. }
  360. // }}}
  361. // {{{ listDatabases()
  362. /**
  363. * list all databases
  364. *
  365. * @return mixed data array on success, a MDB2 error on failure
  366. * @access public
  367. */
  368. function listDatabases()
  369. {
  370. $db =& $this->getDBInstance();
  371. if (PEAR::isError($db)) {
  372. return $db;
  373. }
  374. return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
  375. 'method not implementedd', __FUNCTION__);
  376. }
  377. // }}}
  378. // {{{ listUsers()
  379. /**
  380. * list all users
  381. *
  382. * @return mixed data array on success, a MDB2 error on failure
  383. * @access public
  384. */
  385. function listUsers()
  386. {
  387. $db =& $this->getDBInstance();
  388. if (PEAR::isError($db)) {
  389. return $db;
  390. }
  391. return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
  392. 'method not implemented', __FUNCTION__);
  393. }
  394. // }}}
  395. // {{{ listViews()
  396. /**
  397. * list all views in the current database
  398. *
  399. * @param string database, the current is default
  400. * @return mixed data array on success, a MDB2 error on failure
  401. * @access public
  402. */
  403. function listViews($database = null)
  404. {
  405. $db =& $this->getDBInstance();
  406. if (PEAR::isError($db)) {
  407. return $db;
  408. }
  409. return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
  410. 'method not implemented', __FUNCTION__);
  411. }
  412. // }}}
  413. // {{{ listTableViews()
  414. /**
  415. * list the views in the database that reference a given table
  416. *
  417. * @param string table for which all references views should be found
  418. * @return mixed MDB2_OK on success, a MDB2 error on failure
  419. * @access public
  420. **/
  421. function listTableViews($table)
  422. {
  423. $db =& $this->getDBInstance();
  424. if (PEAR::isError($db)) {
  425. return $db;
  426. }
  427. return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
  428. 'method not implemented', __FUNCTION__);
  429. }
  430. // }}}
  431. // {{{ listTableTriggers()
  432. /**
  433. * This function will be called to get all triggers of the
  434. * current database ($db->getDatabase())
  435. *
  436. * @access public
  437. * @param string $table The name of the table from the
  438. * previous database to query against.
  439. * @return mixed Array on success or MDB2 error on failure
  440. */
  441. function listTableTriggers($table = null)
  442. {
  443. $db =& $this->getDBInstance();
  444. if (PEAR::isError($db)) {
  445. return $db;
  446. }
  447. return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
  448. 'method not implemented', __FUNCTION__);
  449. }
  450. // }}}
  451. // {{{ listFunctions()
  452. /**
  453. * list all functions in the current database
  454. *
  455. * @return mixed data array on success, a MDB2 error on failure
  456. * @access public
  457. */
  458. function listFunctions()
  459. {
  460. $db =& $this->getDBInstance();
  461. if (PEAR::isError($db)) {
  462. return $db;
  463. }
  464. return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
  465. 'method not implemented', __FUNCTION__);
  466. }
  467. // }}}
  468. // {{{ listTables()
  469. /**
  470. * list all tables in the current database
  471. *
  472. * @param string database, the current is default
  473. * @return mixed data array on success, a MDB2 error on failure
  474. * @access public
  475. */
  476. function listTables($database = null)
  477. {
  478. $db =& $this->getDBInstance();
  479. if (PEAR::isError($db)) {
  480. return $db;
  481. }
  482. return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
  483. 'method not implemented', __FUNCTION__);
  484. }
  485. // }}}
  486. // {{{ listTableFields()
  487. /**
  488. * list all fields in a tables in the current database
  489. *
  490. * @param string $table name of table that should be used in method
  491. * @return mixed data array on success, a MDB2 error on failure
  492. * @access public
  493. */
  494. function listTableFields($table)
  495. {
  496. $db =& $this->getDBInstance();
  497. if (PEAR::isError($db)) {
  498. return $db;
  499. }
  500. return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
  501. 'method not implemented', __FUNCTION__);
  502. }
  503. // }}}
  504. // {{{ createIndex()
  505. /**
  506. * Get the stucture of a field into an array
  507. *
  508. * @param string $table name of the table on which the index is to be created
  509. * @param string $name name of the index to be created
  510. * @param array $definition associative array that defines properties of the index to be created.
  511. * Currently, only one property named FIELDS is supported. This property
  512. * is also an associative with the names of the index fields as array
  513. * indexes. Each entry of this array is set to another type of associative
  514. * array that specifies properties of the index that are specific to
  515. * each field.
  516. *
  517. * Currently, only the sorting property is supported. It should be used
  518. * to define the sorting direction of the index. It may be set to either
  519. * ascending or descending.
  520. *
  521. * Not all DBMS support index sorting direction configuration. The DBMS
  522. * drivers of those that do not support it ignore this property. Use the
  523. * function supports() to determine whether the DBMS driver can manage indexes.
  524. *
  525. * Example
  526. * array(
  527. * 'fields' => array(
  528. * 'user_name' => array(
  529. * 'sorting' => 'ascending'
  530. * ),
  531. * 'last_login' => array()
  532. * )
  533. * )
  534. * @return mixed MDB2_OK on success, a MDB2 error on failure
  535. * @access public
  536. */
  537. function createIndex($table, $name, $definition)
  538. {
  539. $db =& $this->getDBInstance();
  540. if (PEAR::isError($db)) {
  541. return $db;
  542. }
  543. $table = $db->quoteIdentifier($table, true);
  544. $name = $db->quoteIdentifier($db->getIndexName($name), true);
  545. $query = "CREATE INDEX $name ON $table";
  546. $fields = array();
  547. foreach (array_keys($definition['fields']) as $field) {
  548. $fields[] = $db->quoteIdentifier($field, true);
  549. }
  550. $query .= ' ('. implode(', ', $fields) . ')';
  551. return $db->exec($query);
  552. }
  553. // }}}
  554. // {{{ dropIndex()
  555. /**
  556. * drop existing index
  557. *
  558. * @param string $table name of table that should be used in method
  559. * @param string $name name of the index to be dropped
  560. * @return mixed MDB2_OK on success, a MDB2 error on failure
  561. * @access public
  562. */
  563. function dropIndex($table, $name)
  564. {
  565. $db =& $this->getDBInstance();
  566. if (PEAR::isError($db)) {
  567. return $db;
  568. }
  569. $name = $db->quoteIdentifier($db->getIndexName($name), true);
  570. return $db->exec("DROP INDEX $name");
  571. }
  572. // }}}
  573. // {{{ listTableIndexes()
  574. /**
  575. * list all indexes in a table
  576. *
  577. * @param string $table name of table that should be used in method
  578. * @return mixed data array on success, a MDB2 error on failure
  579. * @access public
  580. */
  581. function listTableIndexes($table)
  582. {
  583. $db =& $this->getDBInstance();
  584. if (PEAR::isError($db)) {
  585. return $db;
  586. }
  587. return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
  588. 'method not implemented', __FUNCTION__);
  589. }
  590. // }}}
  591. // {{{ createConstraint()
  592. /**
  593. * create a constraint on a table
  594. *
  595. * @param string $table name of the table on which the constraint is to be created
  596. * @param string $name name of the constraint to be created
  597. * @param array $definition associative array that defines properties of the constraint to be created.
  598. * Currently, only one property named FIELDS is supported. This property
  599. * is also an associative with the names of the constraint fields as array
  600. * constraints. Each entry of this array is set to another type of associative
  601. * array that specifies properties of the constraint that are specific to
  602. * each field.
  603. *
  604. * Example
  605. * array(
  606. * 'fields' => array(
  607. * 'user_name' => array(),
  608. * 'last_login' => array()
  609. * )
  610. * )
  611. * @return mixed MDB2_OK on success, a MDB2 error on failure
  612. * @access public
  613. */
  614. function createConstraint($table, $name, $definition)
  615. {
  616. $db =& $this->getDBInstance();
  617. if (PEAR::isError($db)) {
  618. return $db;
  619. }
  620. $table = $db->quoteIdentifier($table, true);
  621. $name = $db->quoteIdentifier($db->getIndexName($name), true);
  622. $query = "ALTER TABLE $table ADD CONSTRAINT $name";
  623. if (!empty($definition['primary'])) {
  624. $query.= ' PRIMARY KEY';
  625. } elseif (!empty($definition['unique'])) {
  626. $query.= ' UNIQUE';
  627. }
  628. $fields = array();
  629. foreach (array_keys($definition['fields']) as $field) {
  630. $fields[] = $db->quoteIdentifier($field, true);
  631. }
  632. $query .= ' ('. implode(', ', $fields) . ')';
  633. return $db->exec($query);
  634. }
  635. // }}}
  636. // {{{ dropConstraint()
  637. /**
  638. * drop existing constraint
  639. *
  640. * @param string $table name of table that should be used in method
  641. * @param string $name name of the constraint to be dropped
  642. * @param string $primary hint if the constraint is primary
  643. * @return mixed MDB2_OK on success, a MDB2 error on failure
  644. * @access public
  645. */
  646. function dropConstraint($table, $name, $primary = false)
  647. {
  648. $db =& $this->getDBInstance();
  649. if (PEAR::isError($db)) {
  650. return $db;
  651. }
  652. $table = $db->quoteIdentifier($table, true);
  653. $name = $db->quoteIdentifier($db->getIndexName($name), true);
  654. return $db->exec("ALTER TABLE $table DROP CONSTRAINT $name");
  655. }
  656. // }}}
  657. // {{{ listTableConstraints()
  658. /**
  659. * list all constraints in a table
  660. *
  661. * @param string $table name of table that should be used in method
  662. * @return mixed data array on success, a MDB2 error on failure
  663. * @access public
  664. */
  665. function listTableConstraints($table)
  666. {
  667. $db =& $this->getDBInstance();
  668. if (PEAR::isError($db)) {
  669. return $db;
  670. }
  671. return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
  672. 'method not implemented', __FUNCTION__);
  673. }
  674. // }}}
  675. // {{{ createSequence()
  676. /**
  677. * create sequence
  678. *
  679. * @param string $seq_name name of the sequence to be created
  680. * @param string $start start value of the sequence; default is 1
  681. * @return mixed MDB2_OK on success, a MDB2 error on failure
  682. * @access public
  683. */
  684. function createSequence($seq_name, $start = 1)
  685. {
  686. $db =& $this->getDBInstance();
  687. if (PEAR::isError($db)) {
  688. return $db;
  689. }
  690. return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
  691. 'method not implemented', __FUNCTION__);
  692. }
  693. // }}}
  694. // {{{ dropSequence()
  695. /**
  696. * drop existing sequence
  697. *
  698. * @param string $seq_name name of the sequence to be dropped
  699. * @return mixed MDB2_OK on success, a MDB2 error on failure
  700. * @access public
  701. */
  702. function dropSequence($name)
  703. {
  704. $db =& $this->getDBInstance();
  705. if (PEAR::isError($db)) {
  706. return $db;
  707. }
  708. return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
  709. 'method not implemented', __FUNCTION__);
  710. }
  711. // }}}
  712. // {{{ listSequences()
  713. /**
  714. * list all sequences in the current database
  715. *
  716. * @param string database, the current is default
  717. * @return mixed data array on success, a MDB2 error on failure
  718. * @access public
  719. */
  720. function listSequences($database = null)
  721. {
  722. $db =& $this->getDBInstance();
  723. if (PEAR::isError($db)) {
  724. return $db;
  725. }
  726. return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
  727. 'method not implemented', __FUNCTION__);
  728. }
  729. }
  730. ?>