Skip to content

Commit

Permalink
Add index reflection into describe()
Browse files Browse the repository at this point in the history
Having one method to do index + column descriptions makes Table easier
to use. It also makes it possible to use index data more easily in other
parts of the framework.
  • Loading branch information
markstory committed May 31, 2013
1 parent a45d462 commit 25863ad
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lib/Cake/Database/Schema/Collection.php
Expand Up @@ -90,12 +90,25 @@ public function describe($name) {

$table = new Table($name);
$fieldParams = [];
if (method_exists($this->_dialect, 'extraSchemaColumn')) {
if (method_exists($this->_dialect, 'extraSchemaColumns')) {
$fieldParams = $this->_dialect->extraSchemaColumns();
}
foreach ($statement->fetchAll('assoc') as $row) {
$this->_dialect->convertFieldDescription($table, $row, $fieldParams);
}

list($sql, $params) = $this->_dialect->describeIndexSql(
$name,
$this->_connection->config()
);
try {
$statement = $this->_connection->execute($sql, $params);
} catch (\PDOException $e) {
return null;
}
foreach ($statement->fetchAll('assoc') as $row) {
$this->_dialect->convertIndexDescription($table, $row);
}
return $table;
}

Expand Down

0 comments on commit 25863ad

Please sign in to comment.