cvs: pear /DB package.xml /DB/DB odbc.php /DB/tests/driver 19getlistof.phpt
| From: | Daniel Convissor | Date: | Sat, 05 Feb 2005 01:49:22 +0000 |
| Subject: | cvs: pear /DB package.xml /DB/DB odbc.php /DB/tests/driver 19getlistof.phpt | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-29143@lists.php.net to get a copy of this message | ||
danielc Fri Feb 4 20:49:22 2005 EDT
Modified files:
/pear/DB package.xml
/pear/DB/DB odbc.php
/pear/DB/tests/driver 19getlistof.phpt
Log:
* Add getListOf() support to odbc. Request 2669.
http://cvs.php.net/diff.php/pear/DB/package.xml?r1=1.162&r2=1.163&ty=u
Index: pear/DB/package.xml
diff -u pear/DB/package.xml:1.162 pear/DB/package.xml:1.163
--- pear/DB/package.xml:1.162 Fri Feb 4 19:41:48 2005
+++ pear/DB/package.xml Fri Feb 4 20:49:22 2005
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<package version="1.0">
- <!-- $Id: package.xml,v 1.162 2005/02/05 00:41:48 danielc Exp $ -->
+ <!-- $Id: package.xml,v 1.163 2005/02/05 01:49:22 danielc Exp $ -->
<name>DB</name>
<summary>Database Abstraction Layer</summary>
<description>
@@ -155,6 +155,7 @@
odbc:
* Add tableInfo() support. Request 2669.
+* Add getListOf() support. Request 2669.
* Add '23504' => DB_ERROR_CONSTRAINT to error map.
* Deal with MS Access' excessive use of the
S1000 ("General Error") code by trying to
http://cvs.php.net/diff.php/pear/DB/DB/odbc.php?r1=1.63&r2=1.64&ty=u
Index: pear/DB/DB/odbc.php
diff -u pear/DB/DB/odbc.php:1.63 pear/DB/DB/odbc.php:1.64
--- pear/DB/DB/odbc.php:1.63 Fri Feb 4 19:41:48 2005
+++ pear/DB/DB/odbc.php Fri Feb 4 20:49:22 2005
@@ -20,7 +20,7 @@
* @author Daniel Convissor <danielc@php.net>
* @copyright 1997-2005 The PHP Group
* @license http://www.php.net/license/3_0.txt
PHP License 3.0
- * @version CVS: $Id: odbc.php,v 1.63 2005/02/05 00:41:48 danielc Exp $
+ * @version CVS: $Id: odbc.php,v 1.64 2005/02/05 01:49:22 danielc Exp $
* @link http://pear.php.net/package/DB
*/
@@ -609,6 +609,76 @@
}
// }}}
+ // {{{ getSpecialQuery()
+
+ /**
+ * Obtain the query string needed for listing a given type of objects
+ *
+ * Thanks to symbol1@gmail.com and Philippe.Jausions@11abacus.com.
+ *
+ * @param string $type the kind of objects you want to retrieve
+ *
+ * @return string the list of objects requested
+ *
+ * @access private
+ * @see DB_common::getListOf()
+ * @since Method available since Release 1.7.0
+ */
+ function getSpecialQuery($type)
+ {
+ switch ($type) {
+ case 'databases':
+ if (version_compare(phpversion(), '4.3.0', '<')) {
+ return null;
+ }
+ $res = @odbc_data_source($this->connection, SQL_FETCH_FIRST);
+ if (is_array($res)) {
+ $out = array($res['server']);
+ while($res = @odbc_data_source($this->connection,
+ SQL_FETCH_NEXT))
+ {
+ $out[] = $res['server'];
+ }
+ return $out;
+ } else {
+ return $this->odbcRaiseError();
+ }
+ break;
+ case 'tables':
+ case 'schema.tables':
+ $keep = 'TABLE';
+ break;
+ case 'views':
+ $keep = 'VIEW';
+ break;
+ default:
+ return null;
+ }
+
+ /*
+ * Removing non-conforming items in the while loop rather than
+ * in the odbc_tables() call because some backends choke on this:
+ * odbc_tables($this->connection, '', '', '',
'TABLE')
+ */
+ $res = @odbc_tables($this->connection);
+ if (!$res) {
+ return $this->odbcRaiseError();
+ }
+ $out = array();
+ while ($row = odbc_fetch_array($res)) {
+ if ($row['TABLE_TYPE'] != $keep) {
+ continue;
+ }
+ if ($type == 'schema.tables') {
+ $out[] = $row['TABLE_SCHEM'] . '.' .
$row['TABLE_NAME'];
+ } else {
+ $out[] = $row['TABLE_NAME'];
+ }
+ }
+ return $out;
+ }
+
+ // }}}
// {{{ tableInfo()
/**
http://cvs.php.net/diff.php/pear/DB/tests/driver/19getlistof.phpt?r1=1.2&r2=1.3&ty=u
Index: pear/DB/tests/driver/19getlistof.phpt
diff -u pear/DB/tests/driver/19getlistof.phpt:1.2 pear/DB/tests/driver/19getlistof.phpt:1.3
--- pear/DB/tests/driver/19getlistof.phpt:1.2 Thu Feb 3 12:03:50 2005
+++ pear/DB/tests/driver/19getlistof.phpt Fri Feb 4 20:49:22 2005
@@ -27,8 +27,8 @@
'mysql:mysql' => 'array',
'mysqli:mysqli' => 'array',
'oci8:oci8' => 'array',
- 'odbc:access' => DB_ERROR_UNSUPPORTED,
- 'odbc:db2' => DB_ERROR_UNSUPPORTED,
+ 'odbc:access' => 'array',
+ 'odbc:db2' => 'array',
'pgsql:pgsql' => 'array',
'sqlite:sqlite' => 'array',
'sybase:sybase' => 'array',
@@ -44,8 +44,8 @@
'mysql:mysql' => DB_ERROR_UNSUPPORTED,
'mysqli:mysqli' => DB_ERROR_UNSUPPORTED,
'oci8:oci8' => DB_ERROR_UNSUPPORTED,
- 'odbc:access' => DB_ERROR_UNSUPPORTED,
- 'odbc:db2' => DB_ERROR_UNSUPPORTED,
+ 'odbc:access' => 'array',
+ 'odbc:db2' => 'array',
'pgsql:pgsql' => 'array',
'sqlite:sqlite' => DB_ERROR_UNSUPPORTED,
'sybase:sybase' => 'array',
@@ -78,8 +78,8 @@
'mysql:mysql' => 'array',
'mysqli:mysqli' => 'array',
'oci8:oci8' => DB_ERROR_UNSUPPORTED,
- 'odbc:access' => DB_ERROR_UNSUPPORTED,
- 'odbc:db2' => DB_ERROR_UNSUPPORTED,
+ 'odbc:access' => 'array',
+ 'odbc:db2' => 'array',
'pgsql:pgsql' => 'array',
'sqlite:sqlite' => DB_ERROR_UNSUPPORTED,
'sybase:sybase' => DB_ERROR_UNSUPPORTED,
@@ -129,8 +129,8 @@
'mysql:mysql' => DB_ERROR_UNSUPPORTED,
'mysqli:mysqli' => DB_ERROR_UNSUPPORTED,
'oci8:oci8' => DB_ERROR_UNSUPPORTED,
- 'odbc:access' => DB_ERROR_UNSUPPORTED,
- 'odbc:db2' => DB_ERROR_UNSUPPORTED,
+ 'odbc:access' => 'array',
+ 'odbc:db2' => 'array',
'pgsql:pgsql' => 'array',
'sqlite:sqlite' => DB_ERROR_UNSUPPORTED,
'sybase:sybase' => DB_ERROR_UNSUPPORTED,