From 25863adbfd27f7ad3028ef4b1a9749ad725f90ea Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 30 May 2013 23:01:56 -0400 Subject: [PATCH] Add index reflection into describe() 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. --- lib/Cake/Database/Schema/Collection.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Database/Schema/Collection.php b/lib/Cake/Database/Schema/Collection.php index 34c9a8f21f8..86bfa492a27 100644 --- a/lib/Cake/Database/Schema/Collection.php +++ b/lib/Cake/Database/Schema/Collection.php @@ -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; }