protected function _create_table($table, $if_not_exists, $attributes)
{
if ($if_not_exists === TRUE && $this->_create_table_if === FALSE) {
if ($this->db->table_exists($table)) {
return TRUE;
} else {
$if_not_exists = FALSE;
}
}
$sql = $if_not_exists ? sprintf($this->_create_table_if, $this->db->escape_identifiers($table)) : 'CREATE TABLE';
$columns = $this->_process_fields(TRUE);
for ($i = 0, $c = count($columns); $i < $c; $i++) {
$columns[$i] = $columns[$i]['_literal'] !== FALSE ? "\n\t" . $columns[$i]['_literal'] : "\n\t" . $this->_process_column($columns[$i]);
}
$columns = implode(',', $columns) . $this->_process_primary_keys($table);
// Are indexes created from within the CREATE TABLE statement? (e.g. in MySQL)
if ($this->_create_table_keys === TRUE) {
$columns .= $this->_process_indexes($table);
}
// _create_table will usually have the following format: "%s %s (%s\n)"
$sql = sprintf($this->_create_table . '%s', $sql, $this->db->escape_identifiers($table), $columns, $this->_create_table_attr($attributes));
return $sql;
}