<?php
/**
 * To copy/paste inside DB/odbc.php DB_odbc class
 */
    // {{{ getListOf()

    /**
     * list internal DB info
     * valid values for $type are db dependent,
     * often:
     *  - databases,
     *  - tables,
     *  - views,
     *  - table_types
     *  - system_tables
     *
     * @param string $type type of requested info
     * @return mixed DB_Error or the requested data
     * @access public
     * @author Philippe.Jausions@11abacus.com
     */
    
function getListOf($type)
    {
        
$info null;
        switch (
$type) {
            case 
'databases':
                if (
function_exists('odbc_data_source')) {
                    
$rs odbc_data_source($this->connectionSQL_FETCH_FIRST);
                    if (
is_array($rs)) {
                        
$info[] = $rs;
                        while (
$rs = @odbc_data_source($this->connectionSQL_FETCH_NEXT)) {
                            
$info[] = $rs;
                        }
                    } else {
                        
$info $this->odbcRaiseError();
                    }
                    return 
$info;
                } else {
                    return 
$this->raiseError(DB_ERROR_UNSUPPORTED);
                }
                break;

            case 
'table_types':
                
$result = @odbc_tables($this->connection'''''''%');
                
$info = array();
                while (@
odbc_fetch_row($result)) {
                    
$table = @odbc_result($result4);
                    if (
$table === false) {
                        
$info $this->odbcRaiseError();
                        break 
2;
                    }
                    
$info[] = odbc_result($result4);
                }
                break;

            default:
                switch (
$type) {
                    case 
'tables':
                        
$type 'TABLE';
                        break;

                    case 
'views':
                        
$type 'VIEW';
                        break;

                    default:
                }
                
// We may get more than we need, but this is the only
                // generic solution I've found for now...
                
$result = @odbc_tables($this->connection);
                
$info = array();
                while (@
odbc_fetch_row($result)) {
                    if (@
odbc_result($result4) == $type) {
                        
$info[] = odbc_result($result3);
                    }
                }
        }

        if (
$result === false) {
            return 
$this->odbcRaiseError();
        }
        
odbc_free_result($result);
        return 
$info;
    }

    
// }}}
?>