mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge pull request #3210 from ubermaniac/Sqlserver-schema-prefix
Sqlserver schema prefix #3208
This commit is contained in:
commit
f9a6c1905b
2 changed files with 10 additions and 6 deletions
|
@ -195,26 +195,30 @@ class Sqlserver extends DboSource {
|
|||
* @throws CakeException
|
||||
*/
|
||||
public function describe($model) {
|
||||
$table = $this->fullTableName($model, false);
|
||||
$cache = parent::describe($table);
|
||||
$table = $this->fullTableName($model, false, false);
|
||||
$fulltable = $this->fullTableName($model, false, true);
|
||||
|
||||
$cache = parent::describe($fulltable);
|
||||
if ($cache) {
|
||||
return $cache;
|
||||
}
|
||||
|
||||
$fields = array();
|
||||
$table = $this->fullTableName($model, false, false);
|
||||
$schema = $model->schemaName;
|
||||
|
||||
$cols = $this->_execute(
|
||||
"SELECT
|
||||
COLUMN_NAME as Field,
|
||||
DATA_TYPE as Type,
|
||||
COL_LENGTH('" . $table . "', COLUMN_NAME) as Length,
|
||||
COL_LENGTH('" . ($schema ? $fulltable : $table) . "', COLUMN_NAME) as Length,
|
||||
IS_NULLABLE As [Null],
|
||||
COLUMN_DEFAULT as [Default],
|
||||
COLUMNPROPERTY(OBJECT_ID('" . $table . "'), COLUMN_NAME, 'IsIdentity') as [Key],
|
||||
COLUMNPROPERTY(OBJECT_ID('" . ($schema ? $fulltable : $table) . "'), COLUMN_NAME, 'IsIdentity') as [Key],
|
||||
NUMERIC_SCALE as Size
|
||||
FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE TABLE_NAME = '" . $table . "'" . ($schema ? " AND TABLE_SCHEMA = '" . $schema . "'" : '')
|
||||
);
|
||||
|
||||
if (!$cols) {
|
||||
throw new CakeException(__d('cake_dev', 'Could not describe table for %s', $table));
|
||||
}
|
||||
|
|
|
@ -3485,7 +3485,7 @@ class Model extends Object implements CakeEventListener {
|
|||
$this->tablePrefix = $db->config['prefix'];
|
||||
}
|
||||
|
||||
$this->schemaName = $db->getSchemaName();
|
||||
$this->schemaName = (empty($this->schemaName) ? $db->getSchemaName() : $this->schemaName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue