Reformating SQLServer 'describe' query.

This commit is contained in:
Mark Story 2011-06-22 08:09:25 -07:00
parent 92bbf1131b
commit 936d068eec

View file

@ -194,7 +194,18 @@ class Sqlserver extends DboSource {
} }
$fields = array(); $fields = array();
$table = $this->fullTableName($model, false); $table = $this->fullTableName($model, false);
$cols = $this->_execute("SELECT COLUMN_NAME as Field, DATA_TYPE as Type, COL_LENGTH('" . $table . "', COLUMN_NAME) as Length, IS_NULLABLE As [Null], COLUMN_DEFAULT as [Default], COLUMNPROPERTY(OBJECT_ID('" . $table . "'), COLUMN_NAME, 'IsIdentity') as [Key], NUMERIC_SCALE as Size FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '" . $table . "'"); $cols = $this->_execute(
"SELECT
COLUMN_NAME as Field,
DATA_TYPE as Type,
COL_LENGTH('" . $table . "', COLUMN_NAME) as Length,
IS_NULLABLE As [Null],
COLUMN_DEFAULT as [Default],
COLUMNPROPERTY(OBJECT_ID('" . $table . "'), COLUMN_NAME, 'IsIdentity') as [Key],
NUMERIC_SCALE as Size
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = '" . $table . "'"
);
if (!$cols) { if (!$cols) {
throw new CakeException(__d('cake_dev', 'Could not describe table for %s', $model->name)); throw new CakeException(__d('cake_dev', 'Could not describe table for %s', $model->name));
} }