public function generateTableSQL($structure) {
        $sql = 'CREATE TABLE' . ' IF NOT EXISTS `' . $structure['table'].'` (' . "\n";

        foreach($structure['columns'] as $column=>$info) {
            if (!is_array($info)) $info = array('type'=>$info);
            if (!isset($info['name'])) $info['name'] = $column;
            if (!empty($info['virtual'])) continue;
            $sql .= $this->generateColumnSQL($info).','."\n";
        }
        if (!empty($structure['indexes'])) {
            foreach($structure['indexes'] as $name=>$info) {
                if (!isset($info['name'])) $info['name'] = $name;
                $sql .= $this->generateIndexSQL($info).','."\n";
            }
        }
        if (!empty($structure['constraints'])) {
            foreach($structure['constraints'] as $info) {
                $info['local_table'] = $structure['table'];
                $sql .= $this->generateConstraintSQL($info).','."\n";
            }
        }
        $sql = substr($sql, 0, -2).')';
        $sql .= ' ENGINE = '.(empty($info['engine']) ? 'INNODB' : $info['engine']).'  CHARACTER SET='.(empty($info['charset']) ? 'utf8' : $info['charset']).' COLLATE='.(empty($info['collate']) ? 'utf8_unicode_ci' : $info['collate']);

        return $sql;
    }
public function generateTableSQL($structure) {
        $sql = 'CREATE TABLE' . ' IF NOT EXISTS `' . $structure['table'].'` (' . "\n";

        foreach($structure['columns'] as $column=>$info) {
            if (!is_array($info)) $info = array('type'=>$info);
            if (!isset($info['name'])) $info['name'] = $column;
            if (!empty($info['virtual'])) continue;
            $sql .= $this->generateColumnSQL($info).','."\n";
        }
        if (!empty($structure['indexes'])) {
            foreach($structure['indexes'] as $name=>$info) {
                if (!isset($info['name'])) $info['name'] = $name;
                $sql .= $this->generateIndexSQL($info).','."\n";
            }
        }
        if (!empty($structure['constraints'])) {
            foreach($structure['constraints'] as $info) {
                $info['local_table'] = $structure['table'];
                $sql .= $this->generateConstraintSQL($info).','."\n";
            }
        }
        $sql = substr($sql, 0, -2).')';
        $sql .= ' ENGINE = '.(empty($info['engine']) ? 'INNODB' : $info['engine']).'  CHARACTER SET='.(empty($info['charset']) ? 'utf8' : $info['charset']).' COLLATE='.(empty($info['collate']) ? 'utf8_unicode_ci' : $info['collate']);

        return $sql;
    }
public function generateTableSQL ( $ structure ) { $ sql = 'CREATE TABLE' . ' IF NOT EXISTS `' . $ structure [ 'table' ] . '` (' . "\n" ; foreach ( $ structure [ 'columns' ] as $ column => $ info ) { if ( ! is_array ( $ info ) ) $ info = array ( 'type' => $ info ) ; if ( ! isset ( $ info [ 'name' ] ) ) $ info [ 'name' ] = $ column ; if ( ! empty ( $ info [ 'virtual' ] ) ) continue ; $ sql .= $ this -> generateColumnSQL ( $ info ) . ',' . "\n" ; } if ( ! empty ( $ structure [ 'indexes' ] ) ) { foreach ( $ structure [ 'indexes' ] as $ name => $ info ) { if ( ! isset ( $ info [ 'name' ] ) ) $ info [ 'name' ] = $ name ; $ sql .= $ this -> generateIndexSQL ( $ info ) . ',' . "\n" ; } } if ( ! empty ( $ structure [ 'constraints' ] ) ) { foreach ( $ structure [ 'constraints' ] as $ info ) { $ info [ 'local_table' ] = $ structure [ 'table' ] ; $ sql .= $ this -> generateConstraintSQL ( $ info ) . ',' . "\n" ; } } $ sql = substr ( $ sql , 0 , - 2 ) . ')' ; $ sql .= ' ENGINE = ' . ( empty ( $ info [ 'engine' ] ) ? 'INNODB' : $ info [ 'engine' ] ) . '  CHARACTER SET=' . ( empty ( $ info [ 'charset' ] ) ? 'utf8' : $ info [ 'charset' ] ) . ' COLLATE=' . ( empty ( $ info [ 'collate' ] ) ? 'utf8_unicode_ci' : $ info [ 'collate' ] ) ; return $ sql ; }
Generate whole SQL definition for table

@param array $structure
@return string
Generate whole SQL definition for table