irm-1.6-b3/MDB/mssql.php
/**
    * Get the flags for a field, currently only supports "isnullable" and "primary_key"
    *
    * @param string The table name
    * @param string The field
    * @access private
    */
Get the flags for a field, currently only supports "isnullable" and "primary_key"
@param string The table name
@param string The field
@access private
Get the flags for a field currently only supports " isnullable " and " primary_key " @param string The table name @param string The field @access private
function _mssql_field_flags($table, $column)
    {
        static $current_table = NULL;
        static $flags;
        if ($table != $current_table) {
            $flags = array();
            $q_nulls = "SELECT syscolumns.name, syscolumns.isnullable
                        FROM sysobjects
                        INNER JOIN syscolumns ON sysobjects.id = syscolumns.id
                        WHERE sysobjects.name ='$table' AND syscolumns.isnullable = 1";
            $res = $this->query($q_nulls, NULL, FALSE);
            $res = $this->fetchAll($res, MDB_FETCHMODE_ASSOC);
            foreach ($res as $data) {
                if ($data['isnullable'] == 1) {
                    $flags[$data['name']][] = 'isnullable';
                }
            }
            $res2 = $this->query("EXEC SP_PKEYS[$table]", NULL, FALSE);
            $res2 = $this->fetchAll($res, MDB_FETCHMODE_ASSOC);
            foreach ($res2 as $data) {
                if (!empty($data['COLUMN_NAME'])) {
                    $flags[$data['COLUMN_NAME']][] = 'primary_key';
                }
            }
            $current_table = $table;
        }
        if (isset($flags[$column])) {
            return(implode(',', $flags[$column]));
        }
        return('');
    }
function _mssql_field_flags ( $ table , $ column ) { static $ current_table = NULL ; static $ flags ; if ( $ table != $ current_table ) { $ flags = array ( ) ; $ q_nulls = " SELECT syscolumns.name, syscolumns.isnullable
                        FROM sysobjects
                        INNER JOIN syscolumns ON sysobjects.id = syscolumns.id
                        WHERE sysobjects.name =' $ table ' AND syscolumns.isnullable = 1 " ; $ res = $ this -> query ( $ q_nulls , NULL , FALSE ) ; $ res = $ this -> fetchAll ( $ res , MDB_FETCHMODE_ASSOC ) ; foreach ( $ res as $ data ) { if ( $ data [ 'isnullable' ] == 1 ) { $ flags [ $ data [ 'name' ] ] [ ] = 'isnullable' ; } } $ res2 = $ this -> query ( " EXEC SP_PKEYS[ $ table ] " , NULL , FALSE ) ; $ res2 = $ this -> fetchAll ( $ res , MDB_FETCHMODE_ASSOC ) ; foreach ( $ res2 as $ data ) { if ( ! empty ( $ data [ 'COLUMN_NAME' ] ) ) { $ flags [ $ data [ 'COLUMN_NAME' ] ] [ ] = 'primary_key' ; } } $ current_table = $ table ; } if ( isset ( $ flags [ $ column ] ) ) { return ( implode ( ',' , $ flags [ $ column ] ) ) ; } return ( '' ) ; }
Get the flags for a field, currently only supports "isnullable" and "primary_key"
 @param string The table name
 @param string The field
 @access private
Get the flags for a field currently only supports " isnullable " and " primary_key " @param string The table name @param string The field @access private
// At the first call we discover the flags for all fields // find nullable fields // find primary keys