Services\ModuleInstaller::createTables PHP Method

createTables() public method

Create new table(s) in DB
public createTables ( $form )
$form
    public function createTables($form)
    {
        if (isset($this->config['info']['vendor'])) {
            $vendor = Str::lower($this->config['info']['vendor']);
        } else {
            $vendor = '';
        }
        $create_sql = "CREATE TABLE IF NOT EXISTS `mdl_{$vendor}_{$form['table']}`";
        $create_sql .= "(`id` int(10) unsigned NOT NULL AUTO_INCREMENT, ";
        foreach ($form['fields'] as $field) {
            $create_sql .= "`{$field}` text COLLATE utf8_unicode_ci NULL, ";
        }
        $create_sql .= "`created_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', `updated_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (`id`)) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;";
        DB::statement($create_sql);
    }