/**
  * Creates a new table
  * @access private
  *
  * @param  CBSimpleXMLElement  $table  Table
  * @param  string              $colNamePrefix    Prefix to add to all column names
  * @return boolean                               True: success, False: failure
  */
 function createTable(&$table, $colNamePrefix)
 {
     if ($table->name() == 'table') {
         $tableName = $this->_prefixedName($table, $colNamePrefix);
         $columns =& $table->getElementByPath('columns');
         if ($tableName && $columns !== false) {
             $sqlColumns = array();
             $tableOptions = array();
             foreach ($columns->children() as $column) {
                 if ($column->name() == 'column') {
                     $colNamePrefixed = $this->_prefixedName($column, $colNamePrefix);
                     $sqlColumns[] = "\n " . $this->_db->NameQuote($colNamePrefixed) . ' ' . $this->_fullColumnType($column);
                     if ((int) $column->attributes('auto_increment')) {
                         $tableOptions[] = 'AUTO_INCREMENT=' . (int) $column->attributes('auto_increment');
                     }
                 }
             }
             $indexes =& $table->getElementByPath('indexes');
             if ($indexes !== false) {
                 foreach ($indexes->children() as $index) {
                     if ($index->name() == 'index') {
                         $sqlIndexText = $this->_fullIndexType($index, $colNamePrefix);
                         if ($sqlIndexText) {
                             $sqlColumns[] = "\n " . $sqlIndexText;
                         }
                     }
                 }
             }
             if ($this->_db->versionCompare('4.0')) {
                 $tableOptions[] = 'ENGINE=MyISAM';
             }
             $collation = $table->attributes('collation');
             if ($collation && $this->_db->versionCompare('4.1')) {
                 $charSet = substr($collation, 0, strpos($collation, '_'));
                 if ($charSet) {
                     $tableOptions[] = 'CHARACTER SET = ' . preg_replace('/[^a-z0-9_]/', '', $charSet);
                     $tableOptions[] = 'COLLATE = ' . preg_replace('/[^a-z0-9_]/', '', $collation);
                 }
             }
             $sql = 'CREATE TABLE ' . $this->_db->NameQuote($tableName) . ' (' . implode(',', $sqlColumns) . "\n )" . implode(', ', $tableOptions);
             if (!$this->_doQuery($sql)) {
                 $this->_setError(sprintf('%s::createTableof Table %s failed with SQL error: %s', get_class($this), $tableName, $this->_db->getErrorMsg()), $sql);
                 return false;
             } else {
                 $this->_setLog(sprintf('Table %s successfully created', $tableName), $sql, 'change');
                 return true;
             }
         }
     }
     return false;
 }