Skip to content

Commit

Permalink
Enable CakePHP ORM to accept PostgreSQL and SQL Server schema.
Browse files Browse the repository at this point in the history
  • Loading branch information
MichalWadowski authored and markstory committed Aug 22, 2014
1 parent c38005d commit bd0daa5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/Database/Schema/Collection.php
Expand Up @@ -107,8 +107,17 @@ public function describe($name, array $options = []) {
return $cached;
}
}
$table = new Table($name);
$config = $this->_connection->config();
if (strpos($name, '.')) {
list($config['schema'], $name) = explode('.', $name);
}

list($sql, $params) = $this->_dialect->describeTableSql($name, $config);
$statement = $this->_executeSql($sql, $params);
if (count($statement) === 0) {
throw new Exception(sprintf('Cannot describe %s. It has 0 columns.', $name));
}
$table = new Table($name);

$this->_reflect('Column', $name, $config, $table);
if (count($table->columns()) === 0) {
Expand Down
1 change: 0 additions & 1 deletion src/Database/Schema/PostgresSchema.php
Expand Up @@ -163,7 +163,6 @@ public function describeIndexSql($table, $config) {
FROM pg_catalog.pg_class c
LEFT JOIN pg_catalog.pg_namespace AS n ON n.oid = c.relnamespace
WHERE c.relname = ?
AND pg_catalog.pg_table_is_visible(c.oid)
AND n.nspname = ?
)
AND c.oid = i.indrelid
Expand Down

0 comments on commit bd0daa5

Please sign in to comment.