Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Implement initial version of _getCreateTableSQL function.

  • Loading branch information...
commit b40d8bb1926c434358c33bd8596d08f4b36a66e3 1 parent 05fed4d
Pádraig O'Sullivan authored
Showing with 42 additions and 1 deletion.
  1. +42 −1 lib/Doctrine/DBAL/Platforms/AkibanServerPlatform.php
43 lib/Doctrine/DBAL/Platforms/AkibanServerPlatform.php
View
@@ -376,7 +376,48 @@ public function getDropForeignKeySQL($foreignKey, $table)
*/
protected function _getCreateTableSQL($tableName, array $columns, array $options = array())
{
- // TODO
+ $columnListSql = $this->getColumnDeclarationListSQL($columns);
+
+ if (isset($options['uniqueConstraints']) && ! empty($options['uniqueConstraints'])) {
+ foreach ($options['uniqueConstraints'] as $name => $definition) {
+ // TODO
+ }
+ }
+
+ if (isset($options['primary']) && ! empty($options['primary'])) {
+ $keyColumns = array_unique(array_values($options['primary']));
+ $columnListSql .= ", PRIMARY KEY(" . implode(", ", $keyColumns) . ")";
+ }
+
+ $query = "CREATE TABLE " . $tableName . " (" . $columnListSql . ")";
+
+ $check = $this->getCheckDeclarationSQL($columns);
+ if ( ! empty($check)) {
+ // TODO
+ }
+
+ $sql[] = $query;
+
+ foreach ($columns as $name => $column) {
+ if (isset($column['sequence'])) {
+ $sql[] = $this->getCreateSequenceSQL($column['sequence'], 1);
+ }
+
+ if (isset($column['autoincrement']) && $column['autoincrement'] ||
+ (isset($column['autoinc']) && $column['autoinc'])) {
+ // TODO??
+ }
+ }
+
+ if (isset($options['indexes']) && ! empty($options['indexes'])) {
+ foreach ($options['indexes'] as $index) {
+ $sql[] = $this->getCreateIndexSQL($index, $tableName);
+ }
+ }
+
+ // TODO - foreign keys
+
+ return $sql;
}
public function getSequenceNextValSQL($sequenceName)
Please sign in to comment.
Something went wrong with that request. Please try again.