irm-1.6-b3/MDB/mysql.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;
        $id     = 0;
        $res  = array();
        if (is_string($result)) {
            if (MDB::isError($connect = $this->connect())) {
                return $connect;
            }
            $id = @mysql_list_fields($this->database_name,
                $result, $this->connection);
            if (empty($id)) {
                return($this->mysqlRaiseError());
            }
        } else { 
            $id = $result;
            if (empty($id)) {
                return($this->mysqlRaiseError());
            }
        }
        $count = @mysql_num_fields($id);
        if (empty($mode)) {
            for ($i = 0, $j = 0; $i<$count; $i++) {
                $name = @mysql_field_name($id, $i);
                if ($name != 'dummy_primary_key') {
                    $res[$j]['table'] = @mysql_field_table($id, $i);
                    $res[$j]['name'] = $name;
                    $res[$j]['type'] = @mysql_field_type($id, $i);
                    $res[$j]['len']  = @mysql_field_len($id, $i);
                    $res[$j]['flags'] = @mysql_field_flags($id, $i);
                    $j++;
                }
            }
        } else { 
            $res['num_fields'] = $count;
            for ($i = 0; $i<$count; $i++) {
                $name = @mysql_field_name($id, $i);
                if ($name != 'dummy_primary_key') {
                    $res[$j]['table'] = @mysql_field_table($id, $i);
                    $res[$j]['name'] = $name;
                    $res[$j]['type'] = @mysql_field_type($id, $i);
                    $res[$j]['len']  = @mysql_field_len($id, $i);
                    $res[$j]['flags'] = @mysql_field_flags($id, $i);
                    if ($mode & MDB_TABLEINFO_ORDER) {
                        $res['order'][$res[$j]['name']] = $i;
                    }
                    if ($mode & MDB_TABLEINFO_ORDERTABLE) {
                        $res['ordertable'][$res[$j]['table']][$res[$j]['name']] = $j;
                    }
                    $j++;
                }
            }
        }
        if (is_string($result)) {
            @mysql_free_result($id);
        }
        return($res);
    }
function tableInfo ( $ result , $ mode = NULL ) { $ count = 0 ; $ id = 0 ; $ res = array ( ) ; if ( is_string ( $ result ) ) { if ( MDB :: isError ( $ connect = $ this -> connect ( ) ) ) { return $ connect ; } $ id = @ mysql_list_fields ( $ this -> database_name , $ result , $ this -> connection ) ; if ( empty ( $ id ) ) { return ( $ this -> mysqlRaiseError ( ) ) ; } } else { $ id = $ result ; if ( empty ( $ id ) ) { return ( $ this -> mysqlRaiseError ( ) ) ; } } $ count = @ mysql_num_fields ( $ id ) ; if ( empty ( $ mode ) ) { for ( $ i = 0 , $ j = 0 ; $ i < $ count ; $ i ++ ) { $ name = @ mysql_field_name ( $ id , $ i ) ; if ( $ name != 'dummy_primary_key' ) { $ res [ $ j ] [ 'table' ] = @ mysql_field_table ( $ id , $ i ) ; $ res [ $ j ] [ 'name' ] = $ name ; $ res [ $ j ] [ 'type' ] = @ mysql_field_type ( $ id , $ i ) ; $ res [ $ j ] [ 'len' ] = @ mysql_field_len ( $ id , $ i ) ; $ res [ $ j ] [ 'flags' ] = @ mysql_field_flags ( $ id , $ i ) ; $ j ++ ; } } } else { $ res [ 'num_fields' ] = $ count ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { $ name = @ mysql_field_name ( $ id , $ i ) ; if ( $ name != 'dummy_primary_key' ) { $ res [ $ j ] [ 'table' ] = @ mysql_field_table ( $ id , $ i ) ; $ res [ $ j ] [ 'name' ] = $ name ; $ res [ $ j ] [ 'type' ] = @ mysql_field_type ( $ id , $ i ) ; $ res [ $ j ] [ 'len' ] = @ mysql_field_len ( $ id , $ i ) ; $ res [ $ j ] [ 'flags' ] = @ mysql_field_flags ( $ id , $ i ) ; if ( $ mode & MDB_TABLEINFO_ORDER ) { $ res [ 'order' ] [ $ res [ $ j ] [ 'name' ] ] = $ i ; } if ( $ mode & MDB_TABLEINFO_ORDERTABLE ) { $ res [ 'ordertable' ] [ $ res [ $ j ] [ 'table' ] ] [ $ res [ $ j ] [ 'name' ] ] = $ j ; } $ j ++ ; } } } if ( is_string ( $ result ) ) { @ mysql_free_result ( $ id ) ; } return ( $ res ) ; }
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
/*
         * depending on $mode, metadata returns the following values:
         *
         * - mode is false (default):
         * $result[]:
         *   [0]['table']  table name
         *   [0]['name']   field name
         *   [0]['type']   field type
         *   [0]['len']    field length
         *   [0]['flags']  field flags
         *
         * - mode is MDB_TABLEINFO_ORDER
         * $result[]:
         *   ['num_fields'] number of metadata records
         *   [0]['table']  table name
         *   [0]['name']   field name
         *   [0]['type']   field type
         *   [0]['len']    field length
         *   [0]['flags']  field flags
         *   ['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['meta']['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 MDB_TABLEINFO_ORDER and
         *      MDB_TABLEINFO_ORDERTABLE with MDB_TABLEINFO_ORDER |
         *      MDB_TABLEINFO_ORDERTABLE * or with MDB_TABLEINFO_FULL
         */ // if $result is a string, then we want information about a // table without a resultset // else we want information about a resultset // made this IF due to performance (one if is faster than $count if's) // full // note sure if this should be $i or $j // free the result only if we were called on a table