..., // 'constraint' => ..., // 'index' => ..., // ) foreach($columns as $colname => $type) { if(is_numeric($colname)) { $colname = $type; } $column_array[$colname] = array(); $column_array[$colname]['type'] = ($type !== $colname) ? $type : ''; } if( ! empty($constraints)) { foreach($constraints as $col => $const) { $column_array[$col]['constraint'] = $const; } } // Join column definitons together $columns = array(); foreach($column_array as $n => $props) { $str = "{$n} "; $str .= (isset($props['type'])) ? "{$props['type']} " : ""; $str .= (isset($props['constraint'])) ? $props['constraint'] : ""; $columns[] = $str; } // Generate the sql for the creation of the table $sql = "CREATE TABLE \"{$name}\" ("; $sql .= implode(", ", $columns); $sql .= ")"; return $sql; } // -------------------------------------------------------------------------- /** * Database-specific SQL for dropping a table * * @param string $name * @return string */ public function delete_table($name) { return 'DROP TABLE "'.$name.'"'; } // -------------------------------------------------------------------------- /** * Create an SQL backup file for the current database's structure * * @return string */ public function backup_structure() { // @todo Implement Backup function return ''; } // -------------------------------------------------------------------------- /** * Create an SQL backup file for the current database's data * * @return string */ public function backup_data() { // @todo Implement Backup function return ''; } } // End of pgsql_util.php