irm-1.6-b3/MDB/mssql.php
/**
     * Returns information about a table or a result set
     *
     * NOTE: doesn't support table name and flags if called from a db_result
     *
     * @param  mixed $resource SQL Server result identifier or table name
     * @param  int $mode A valid tableInfo mode (MDB_TABLEINFO_ORDERTABLE or
     *                   MDB_TABLEINFO_ORDER)
     *
     * @return array An array with all the information
     */
Returns information about a table or a result set
NOTE: doesn't support table name and flags if called from a db_result

@param  mixed $resource SQL Server result identifier or table name
@param  int $mode A valid tableInfo mode (MDB_TABLEINFO_ORDERTABLE or
MDB_TABLEINFO_ORDER)

@return array An array with all the information
Returns information about a table or a result set NOTE : doesn ' t support table name and flags if called from a db_result @param mixed $resource SQL Server result identifier or table name @param int $mode A valid tableInfo mode ( MDB_TABLEINFO_ORDERTABLE or MDB_TABLEINFO_ORDER ) @return array An array with all the information
function tableInfo($result, $mode = NULL)
    {
        $count = 0;
        $id    = 0;
        $res   = array();
        if (is_string($result)) {
            if (!@mssql_select_db($this->database_name, $this->connection)) {
                return $this->mssqlRaiseError();
            }
            $id = @mssql_query("SELECT * FROM $result", $this->connection);
            if (empty($id)) {
                return($this->mssqlRaiseError());
            }
        } else { 
            $id = $result;
            if (empty($id)) {
                return($this->mssqlRaiseError());
            }
        }
        $count = @mssql_num_fields($id);
        if (empty($mode)) {
            for ($i=0; $i<$count; $i++) {
                $res[$i]['table'] = (is_string($result)) ? $result : '';
                $res[$i]['name']  = @mssql_field_name($id, $i);
                $res[$i]['type']  = @mssql_field_type($id, $i);
                $res[$i]['len']   = @mssql_field_length($id, $i);
                $res[$i]['flags'] = is_string($result) ? $this->_mssql_field_flags($result, $res[$i]['name']) : '';
            }
        } else { 
            $res['num_fields']= $count;
            for ($i=0; $i<$count; $i++) {
                $res[$i]['table'] = (is_string($result)) ? $result : '';
                $res[$i]['name']  = @mssql_field_name($id, $i);
                $res[$i]['type']  = @mssql_field_type($id, $i);
                $res[$i]['len']   = @mssql_field_length($id, $i);
                $res[$i]['flags'] = is_string($result) ? $this->_mssql_field_flags($result, $res[$i]['name']) : '';
                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 (is_string($result)) {
            @mssql_free_result($id);
        }
        return($res);
    }
function tableInfo ( $ result , $ mode = NULL ) { $ count = 0 ; $ id = 0 ; $ res = array ( ) ; if ( is_string ( $ result ) ) { if ( ! @ mssql_select_db ( $ this -> database_name , $ this -> connection ) ) { return $ this -> mssqlRaiseError ( ) ; } $ id = @ mssql_query ( " SELECT * FROM  $ result " , $ this -> connection ) ; if ( empty ( $ id ) ) { return ( $ this -> mssqlRaiseError ( ) ) ; } } else { $ id = $ result ; if ( empty ( $ id ) ) { return ( $ this -> mssqlRaiseError ( ) ) ; } } $ count = @ mssql_num_fields ( $ id ) ; if ( empty ( $ mode ) ) { for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { $ res [ $ i ] [ 'table' ] = ( is_string ( $ result ) ) ? $ result : '' ; $ res [ $ i ] [ 'name' ] = @ mssql_field_name ( $ id , $ i ) ; $ res [ $ i ] [ 'type' ] = @ mssql_field_type ( $ id , $ i ) ; $ res [ $ i ] [ 'len' ] = @ mssql_field_length ( $ id , $ i ) ; $ res [ $ i ] [ 'flags' ] = is_string ( $ result ) ? $ this -> _mssql_field_flags ( $ result , $ res [ $ i ] [ 'name' ] ) : '' ; } } else { $ res [ 'num_fields' ] = $ count ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { $ res [ $ i ] [ 'table' ] = ( is_string ( $ result ) ) ? $ result : '' ; $ res [ $ i ] [ 'name' ] = @ mssql_field_name ( $ id , $ i ) ; $ res [ $ i ] [ 'type' ] = @ mssql_field_type ( $ id , $ i ) ; $ res [ $ i ] [ 'len' ] = @ mssql_field_length ( $ id , $ i ) ; $ res [ $ i ] [ 'flags' ] = is_string ( $ result ) ? $ this -> _mssql_field_flags ( $ result , $ res [ $ i ] [ 'name' ] ) : '' ; 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 ( is_string ( $ result ) ) { @ mssql_free_result ( $ id ) ; } return ( $ res ) ; }
Returns information about a table or a result set
 NOTE: doesn't support table name and flags if called from a db_result
Returns information about a table or a result set NOTE : doesn ' t support table name and flags if called from a db_result
/*
         * 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) // We only support flags for tables // full // We only support flags for tables // free the result only if we were called on a table