irm-1.6-b3/MDB/oci8.php
/**
     * returns meta data about the result set
     * 
     * @param resource $result result identifier
     * @param mixed $mode depends on implementation
     * @return array an nested array, or a MDB error
     * @access public 
     */
returns meta data about the result set

@param resource $result result identifier
@param mixed $mode depends on implementation
@return array an nested array, or a MDB error
@access public
returns meta data about the result set @param resource $result result identifier @param mixed $mode depends on implementation @return array an nested array or a MDB error @access public
function tableInfo($result, $mode = NULL)
    {
        $count = 0;
        $res = array();
        if (is_string($result)) {
            if (MDB::isError($connect = $this->connect())) {
                return($connect);
            }
            $result = strtoupper($result);
            $q_fields = "select column_name, data_type, data_length, data_precision,
                     nullable, data_default from user_tab_columns
                     where table_name='$result' order by column_id";
            if (!$stmt = @OCIParse($this->connection, $q_fields)) {
                return($this->oci8RaiseError());
            }
            if (!@OCIExecute($stmt, OCI_DEFAULT)) {
                return($this->oci8RaiseError($stmt));
            } while (@OCIFetch($stmt)) {
                $res[$count]['table'] = strtolower($result);
                $res[$count]['name'] = strtolower(@OCIResult($stmt, 1));
                $res[$count]['type'] = strtolower(@OCIResult($stmt, 2));
                $res[$count]['len'] = @OCIResult($stmt, 3);
                $res[$count]['format'] = @OCIResult($stmt, 4);
                $res[$count]['nullable'] = (@OCIResult($stmt, 5) == 'Y') ? TRUE : FALSE;
                $res[$count]['default'] = @OCIResult($stmt, 6);
                if ($mode & MDB_TABLEINFO_ORDER) {
                    $res['order'][$res[$count]['name']] = $count;
                }
                if ($mode & MDB_TABLEINFO_ORDERTABLE) {
                    $res['ordertable'][$res[$count]['table']][$res[$count]['name']] = $count;
                }
                $count++;
            }
            if ($mode) {
                $res['num_fields'] = $count;
            }
            @OCIFreeStatement($stmt);
        } else { 
                $count = @OCINumCols($result);
                for ($i = 0; $i < $count; $i++) {
                    $res[$i]['name'] = strtolower(@OCIColumnName($result, $i + 1));
                    $res[$i]['type'] = strtolower(@OCIColumnType($result, $i + 1));
                    $res[$i]['len'] = @OCIColumnSize($result, $i + 1);
                    $q_fields = "SELECT table_name, data_precision, nullable, data_default from user_tab_columns WHERE column_name='".$res[$i]['name']."'";
                    if (!$stmt = @OCIParse($this->connection, $q_fields)) {
                        return($this->oci8RaiseError());
                    }
                    if (!@OCIExecute($stmt, OCI_DEFAULT)) {
                        return($this->oci8RaiseError($stmt));
                    }
                    @OCIFetch($stmt);
                    $res[$i]['table'] = strtolower(@OCIResult($stmt, 1));
                    $res[$i]['format'] = @OCIResult($stmt, 2);
                    $res[$i]['nullable'] = (@OCIResult($stmt, 3) == 'Y') ? TRUE : FALSE;
                    $res[$i]['default'] = @OCIResult($stmt, 4);
                    @OCIFreeStatement($stmt);
                    if ($mode & MDB_TABLEINFO_ORDER) {
                        $res['order'][$res[$i]['name']] = $i;
                    }
                    if ($mode & MDB_TABLEINFO_ORDERTABLE) {
                        $res['ordertable'][$res[$i]['table']][$res[$i]['name']] = $i;
                    }
                }
                if ($mode) {
                    $res['num_fields'] = $count;
                }
        }
        return($res);
    }
function tableInfo ( $ result , $ mode = NULL ) { $ count = 0 ; $ res = array ( ) ; if ( is_string ( $ result ) ) { if ( MDB :: isError ( $ connect = $ this -> connect ( ) ) ) { return ( $ connect ) ; } $ result = strtoupper ( $ result ) ; $ q_fields = " select column_name, data_type, data_length, data_precision,
                     nullable, data_default from user_tab_columns
                     where table_name=' $ result ' order by column_id " ; if ( ! $ stmt = @ OCIParse ( $ this -> connection , $ q_fields ) ) { return ( $ this -> oci8RaiseError ( ) ) ; } if ( ! @ OCIExecute ( $ stmt , OCI_DEFAULT ) ) { return ( $ this -> oci8RaiseError ( $ stmt ) ) ; } while ( @ OCIFetch ( $ stmt ) ) { $ res [ $ count ] [ 'table' ] = strtolower ( $ result ) ; $ res [ $ count ] [ 'name' ] = strtolower ( @ OCIResult ( $ stmt , 1 ) ) ; $ res [ $ count ] [ 'type' ] = strtolower ( @ OCIResult ( $ stmt , 2 ) ) ; $ res [ $ count ] [ 'len' ] = @ OCIResult ( $ stmt , 3 ) ; $ res [ $ count ] [ 'format' ] = @ OCIResult ( $ stmt , 4 ) ; $ res [ $ count ] [ 'nullable' ] = ( @ OCIResult ( $ stmt , 5 ) == 'Y' ) ? TRUE : FALSE ; $ res [ $ count ] [ 'default' ] = @ OCIResult ( $ stmt , 6 ) ; if ( $ mode & MDB_TABLEINFO_ORDER ) { $ res [ 'order' ] [ $ res [ $ count ] [ 'name' ] ] = $ count ; } if ( $ mode & MDB_TABLEINFO_ORDERTABLE ) { $ res [ 'ordertable' ] [ $ res [ $ count ] [ 'table' ] ] [ $ res [ $ count ] [ 'name' ] ] = $ count ; } $ count ++ ; } if ( $ mode ) { $ res [ 'num_fields' ] = $ count ; } @ OCIFreeStatement ( $ stmt ) ; } else { $ count = @ OCINumCols ( $ result ) ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { $ res [ $ i ] [ 'name' ] = strtolower ( @ OCIColumnName ( $ result , $ i + 1 ) ) ; $ res [ $ i ] [ 'type' ] = strtolower ( @ OCIColumnType ( $ result , $ i + 1 ) ) ; $ res [ $ i ] [ 'len' ] = @ OCIColumnSize ( $ result , $ i + 1 ) ; $ q_fields = " SELECT table_name, data_precision, nullable, data_default from user_tab_columns WHERE column_name=' " . $ res [ $ i ] [ 'name' ] . " ' " ; if ( ! $ stmt = @ OCIParse ( $ this -> connection , $ q_fields ) ) { return ( $ this -> oci8RaiseError ( ) ) ; } if ( ! @ OCIExecute ( $ stmt , OCI_DEFAULT ) ) { return ( $ this -> oci8RaiseError ( $ stmt ) ) ; } @ OCIFetch ( $ stmt ) ; $ res [ $ i ] [ 'table' ] = strtolower ( @ OCIResult ( $ stmt , 1 ) ) ; $ res [ $ i ] [ 'format' ] = @ OCIResult ( $ stmt , 2 ) ; $ res [ $ i ] [ 'nullable' ] = ( @ OCIResult ( $ stmt , 3 ) == 'Y' ) ? TRUE : FALSE ; $ res [ $ i ] [ 'default' ] = @ OCIResult ( $ stmt , 4 ) ; @ OCIFreeStatement ( $ stmt ) ; if ( $ mode & MDB_TABLEINFO_ORDER ) { $ res [ 'order' ] [ $ res [ $ i ] [ 'name' ] ] = $ i ; } if ( $ mode & MDB_TABLEINFO_ORDERTABLE ) { $ res [ 'ordertable' ] [ $ res [ $ i ] [ 'table' ] ] [ $ res [ $ i ] [ 'name' ] ] = $ i ; } } if ( $ mode ) { $ res [ 'num_fields' ] = $ count ; } } return ( $ res ) ; }
returns meta data about the result set
returns meta data about the result set
/**
         * depending on $mode, metadata returns the following values:
         * 
         * - mode is FALSE (default):
         * $res[]:
         *    [0]['table']       table name
         *    [0]['name']        field name
         *    [0]['type']        field type
         *    [0]['len']         field length
         *    [0]['nullable']    field can be NULL (boolean)
         *    [0]['format']      field precision if NUMBER
         *    [0]['default']     field default value
         * 
         * - mode is MDB_TABLEINFO_ORDER
         * $res[]:
         *    ['num_fields']     number of fields
         *    [0]['table']       table name
         *    [0]['name']        field name
         *    [0]['type']        field type
         *    [0]['len']         field length
         *    [0]['nullable']    field can be NULL (boolean)
         *    [0]['format']      field precision if NUMBER
         *    [0]['default']     field default value
         *    ['order'][field name] index of field named 'field name'
         *    The last one is used, if you have a field name, but no index.
         *    Test:  if (isset($result['order']['myfield'])) { ...
         * 
         * - mode is MDB_TABLEINFO_ORDERTABLE
         *     the same as above. but additionally
         *    ['ordertable'][table name][field name] index of field
         *       named 'field name'
         * 
         *       this is, because if you have fields from different
         *       tables with the same field name * they override each
         *       other with MDB_TABLEINFO_ORDER
         * 
         *       you can combine DB_TABLEINFO_ORDER and
         *       MDB_TABLEINFO_ORDERTABLE with MDB_TABLEINFO_ORDER |
         *       MDB_TABLEINFO_ORDERTABLE * or with MDB_TABLEINFO_FULL
         */ // if $result is a string, we collect info for a table only // else we want information about a resultset #if ($result === $this->last_stmt) { #} else { #    return($this->raiseError(MDB_ERROR_NOT_CAPABLE)); #}