Skip to content
Permalink
Browse files

Add basic describe() to MySQL.

Primary key, indexes, and platform specifics still need to be implemented.
  • Loading branch information...
markstory committed Mar 25, 2013
1 parent 001ecae commit c24d6e6dce1078c6b114c15d0a70fafcf4f85630
@@ -449,10 +449,20 @@ public function listTables() {
* @return array The schema data for the requested table.
*/
public function describe($table) {
$this->connect();
$result = $this->execute($this->_driver->describeTableSql(), ['table' => $table]);
list($sql, $params) = $this->_driver->describeTableSql($table);
$statement = $this->execute($sql, $params);
$schema = [];
// TODO complete.
// TODO add tableParameters for platform specific features.
while ($row = $statement->fetch('assoc')) {
list($type, $length) = $this->_driver->columnType($row['Type']);
$schema[$row['Field']] = [
'type' => $type,
'null' => $row['Null'] === 'YES' ? true : false,
'default' => $row['Default'],
'length' => $length,
];
}
return $schema;
}
@@ -242,8 +242,7 @@ public function testDescribeTable() {
'type' => 'biginteger',
'null' => false,
'default' => null,
'length' => 8,
'primary' => true
'length' => 20,
],
'title' => [
'type' => 'string',

0 comments on commit c24d6e6

Please sign in to comment.
You can’t perform that action at this time.