Creation of the table
@access public
@return void
@since 3.0
@package Gcs\Framework\Core\Orm\Entity
339920
final protected function _tableDefinition() {
        $annotation = Annotation::getClass($this);

        /** @var \ReflectionClass $fieldClass */
        $fieldClass = new \ReflectionClass('\\Gcs\Framework\Core\\Orm\\Entity\\Field');
        /** @var \ReflectionClass $foreignKeyClass */
        $foreignKeyClass = new \ReflectionClass('\\Gcs\Framework\Core\\Orm\\Entity\\ForeignKey');
        /** @var \ReflectionClass $builderClass */
        $builderClass = new \ReflectionClass('\\Gcs\Framework\Core\\Orm\\Builder');

        foreach ($annotation['class'] as $annotationClass) {
            $instance = $annotationClass[0]['instance'];

            switch ($annotationClass[0]['annotation']) {
                case 'Table':
                    $this->name($instance->name);
                    break;

                case 'Form':
                    $this->form($instance->name);
                    break;
            }
        }

        foreach ($annotation['properties'] as $name => $annotationProperties) {
            foreach ($annotationProperties as $annotationProperty) {
                $instance = $annotationProperty['instance'];

                if ($annotationProperty['annotation'] == 'Column') {
                    $this->field($name)->type($fieldClass->getConstant($instance->type))->size($instance->size)->beNull($instance->null == 'true' ? true : false)->primary($instance->primary == 'true' ? true : false)->unique($instance->unique == 'true' ? true : false)->precision($instance->precision)->defaultValue($instance->default)->enum($instance->enum != '' ? explode(',', $instance->enum) : []);

                    $fieldType = $fieldClass->getConstant($instance->type);

                    if (in_array($fieldType, [Field::DATETIME, Field::DATE, Field::TIMESTAMP])) {
                        $this->set($name, new \DateTime());
                    }
                }
                else {
                    $this->field($name)->foreign(['type' => $foreignKeyClass->getConstant($instance->type), 'reference' => explode('.', $instance->to), 'current' => explode('.', $instance->from), 'belong' => $foreignKeyClass->getConstant($instance->belong), 'join' => $builderClass->getConstant($instance->join),]);

                    $foreignType = $foreignKeyClass->getConstant($instance->type);

                    if (in_array($foreignType, [ForeignKey::MANY_TO_MANY, ForeignKey::ONE_TO_MANY])) {
                        $this->set($name, new Collection());
                    }
                }
            }
        }
    }
1059999
public function createTable()
    {
        if ($this->tableExists() === true) {
            return true;
        }

        $dbh      = $this->db();
        $driver   = $dbh->getAttribute(PDO::ATTR_DRIVER_NAME);
        $model    = $this->model();
        $metadata = $model->metadata();

        $table   = $this->table();
        $fields  = $this->getModelFields($model);
        $columns = [];
        foreach ($fields as $field) {
            $columns[] = $field->sql();
        }

        $query  = 'CREATE TABLE  `'.$table.'` ('."\n";
        $query .= implode(',', $columns);

        $key = $model->key();
        if ($key) {
            $query .= ', PRIMARY KEY (`'.$key.'`) '."\n";
        }

        /** @todo Add indexes for all defined list constraints (yea... tough job...) */
        if ($driver === self::MYSQL_DRIVER_NAME) {
            $engine = 'InnoDB';
            $query .= ') ENGINE='.$engine.' DEFAULT CHARSET=utf8 COMMENT="'.addslashes($metadata['name']).'";';
        } else {
            $query .= ');';
        }

        $this->logger->debug($query);
        $dbh->query($query);

        return true;
    }
748754
public function makeMigration()
    {
        $tableName = $this->ask('Table Name (Example: users)');

        if ($this->confirm('Are you creating a new table')) {
            $this->info('Setting create option for table '. $tableName);

            $this->options['--create'] = $tableName;
            $this->options['name'] = 'create_'. $tableName .'_table';
        } else {
            $this->info('Setting table option for table '. $tableName);

            $this->options['--table'] = $this->options['name'];
            $this->options['name'] = $this->ask('Migration Name (Example: alter_user_table_add_column_is_admin)', 'alter_'. $tableName .'_table_'. rand(0, 100));
        }

        if (! $this->confirm('Use default migration folder?', 'yes')) {
            $this->options['path'] = $this->ask('Path for Migration');
        }
    }
526740
function createTables() {
            return Promise.all(Object.keys(CRUD.EntityManager.entities).map(function(entityName) {
                var entity = CRUD.EntityManager.entities[entityName];
                if (tables.indexOf(entity.table) == -1) {
                    if (!entity.createStatement) {
                        throw "No create statement found for " + entity.getType() + ". Don't know how to create table.";
                    }
                    return db.execute(entity.createStatement).then(function() {
                        tables.push(entity.table);
                        localStorage.setItem('database.version.' + entity.table, ('migrations' in entity) ? Math.max.apply(Math, Object.keys(entity.migrations)) : 1);
                        CRUD.log(entity.table + " table created.");
                        return entity;
                    }, function(err) {
                        CRUD.log("Error creating " + entity.table, err, entity.createStatement);
                        throw "Error creating table: " + entity.table;
                    }).then(createFixtures).then(function() {
                        CRUD.log("Table created and fixtures inserted for ", entityName);
                        return;
                    });
                }
                return;
            }));
        }
56362
public function createRepository()
    {
        $schema = $this->connection->getSchemaBuilder();

        $schema->create($this->table, function ($table) {
            $table->string('migration');
            $table->string('extension')->nullable();
        });
    }
1140138
public function create()
        {
            $sql = $this->generateCreateSql();
            $query = new RawQuery($sql);
            try {
                $this->drop();
                return Statement::getPreparedStatement($query)->execute();
            } catch (\Exception $e) {
                throw new Exception('Error creating table ' . $this->getB2DBName() . ': ' . $e->getMessage(), $sql);
            }
        }
1160296
public function createQueue()
    {
        $persistence = $this->getPersistence();
        /** @var AbstractSchemaManager $schemaManager */
        $schemaManager = $persistence->getDriver()->getSchemaManager();

        /** @var Schema $schema */
        $schema = $schemaManager->createSchema();
        $fromSchema = clone $schema;
        try {
            if (in_array($this->getTableName(), $schemaManager->getTables())) {
                $schema->dropTable($this->getTableName());
            }
            $table = $schema->createTable($this->getTableName());
            $table->addOption('engine', 'InnoDB');
            $table->addColumn('id', 'integer', ["autoincrement" => true, "notnull" => true, "unsigned" => true]);
            $table->addColumn('message', 'text', ["notnull" => true]);
            $table->addColumn('visible', 'boolean', ["default" => 1]);
            $table->addColumn('created_at', 'datetime', ['notnull' => true]);
            $table->setPrimaryKey(['id']);
            $table->addIndex(['created_at', 'visible'], 'IDX_created_at_visible_'. $this->getQueueName());

        } catch (SchemaException $e) {
            $this->logDebug('Schema of '. $this->getTableName() .' table already up to date.');
        }

        $queries = $persistence->getPlatForm()->getMigrateSchemaSql($fromSchema, $schema);

        foreach ($queries as $query) {
            $persistence->exec($query);
        }

        if ($queries) {
            $this->logDebug('Queue '. $this->getTableName() .' created/updated in RDS.');
        }
    }
739127
public function createRepository()
    {
        $this->schema()->create($this->table, function ($table) {

            // The mappings table is responsible for keeping track of which of the
            // mappings have actually run for the application. We'll create the
            // table to hold the mapping file's path as well as the batch ID.
            $table->increments('id');

            $table->string('mapping');

            $table->integer('batch');
        });
    }
481879
public function create()
    {
        $this->loadModel('Content.ContentTypes');
        $types = $this->ContentTypes->find()
            ->select(['id', 'slug', 'name', 'description'])
            ->all();

        $this->title(__d('content', 'Create New Content'));
        $this->set('types', $types);
        $this->Breadcrumb
            ->push('/admin/content/manage')
            ->push(__d('content', 'Create new content'), '');
    }
515375
public function create()
    {
        try {
            $this->pdo->exec("CREATE DATABASE `{$this->dbName}`");
        } catch (PDOException $e) {
            //SQLite does not support this...
        }

        $sql = <<<SQL
            CREATE TABLE IF NOT EXISTS `{$this->dbName}`.`{$this->dbTable}` (
                `eid` int(10) NOT NULL,
                `id` int(10) NOT NULL,
                `type` int(4) NOT NULL,
                `description` varchar(255) NOT NULL,
                `months` int(11) NOT NULL,
                `interestrate` decimal(11,2) NOT NULL,
                `invoicefee` decimal(11,2) NOT NULL,
                `startfee` decimal(11,2) NOT NULL,
                `minamount` decimal(11,2) NOT NULL,
                `country` int(11) NOT NULL,
                `expire` int(11) NOT NULL
            );
SQL;
        try {
            $this->pdo->exec($sql);
        } catch (PDOException $e) {
            throw new Klarna_DatabaseException(
                'Table non-existant, failed to create it!'
            );
        }
    }
216966
public function generateMigration()
    {
        if (!$this->confirm('Do you want to create a migration?')) {
            return;
        }

        $existing = $this->existing();
        $table = $this->getEntities();

        $this->console->call('generate:migration', [
            'name' => $existing ? $table : "create_{$table}_table",
            '--fields' => $this->console->option('fields'),
            '--force' => $this->console->option('force'),
            '--existing' => $existing,
        ]);
    }
1163533
public function createSQL()
	{
		try {

			$lines = array();

			$indices = array();

			$columns = $this->columns;

			$template = "CREATE TABLE %s (\n%s,\n%s\n) ENGINE=%s DEFAULT CHARSET=%s;";

			foreach ($this->columns as $column_name => $column)
			{

				//$column_name = $column["name"];//set the column name

				$data_type = $column["type"];//set the column data type

				$length = $column["length"];//set the lenght of the data type

				if ($column["primary"])	$indices[] = "PRIMARY KEY ({$column_name})"; //add primary key field

				if ($column["index"]) $indices[] = "KEY {$column_name} ({$column_name})"; //add index field

				switch ($data_type)
				{
					case "autonumber":

						$lines[] = "{$column_name} INT(11) NOT NULL AUTO_INCREMENT";

						break;

					case "text":

						if ($length !== null && $length <= 255)	$lines[] = "{$column_name} VARCHAR({$length}) DEFAULT NULL";

						else $lines[] = "{$column_name} text";

						break;

					case "integer":

						$lines[] = "{$column_name} INT(11) DEFAULT NULL";

						break;

					case "decimal":

						$lines[] = "{$column_name} FLOAT DEFAULT NULL";

						break;

					case "boolean":

						$lines[] = "{$column_name} TINYINT(4) DEFAULT NULL";

						break;

					case "datetime":

						$lines[] = "{$column_name} DATETIME DEFAULT NULL";

						break;

				}

			}

			$this->query_string = sprintf($template, $this->table, join(",\n", $lines), join(",\n", $indices), 'InnoDB', 'utf8');//$this->connection->character_set_name()
			
			return $this;

		} catch (MySQLException $e) {

			$e->errorShow();

		}
		
	}
345867
protected function createTables()
    {
        if (empty( self::$tables )) {
            throw new \Exception('Cannot create tables, as no configuration file given, or the ::$tables is not overridden.');
        }
        $client = $this->dynamoDb->getClient();

        foreach (self::$tables as $tableData) {
            $tableName = $tableData['TableName'];

            if ( ! $this->tableExists($tableName)) {
                $this->comment(sprintf('Creating table %s', $tableName));

                $client->createTable($tableData);

                $client->waitUntil('TableExists', array(
                    'TableName' => $tableName,
                ));

                $this->info(sprintf('Table "%s" created.', $tableName));
            } else {
                $this->warn(sprintf('Table "%s" already exists.', $tableName));
            }
        }
    }
767174
private function initialize() {
        
        // lets create the table if it does not yet exists 
        $this->cassandraConnection->execute(
            new SimpleStatement("CREATE TABLE IF NOT EXISTS ".$this->table." (channel VARCHAR, level INT, message TEXT, time timestamp, PRIMARY KEY (channel, level, time) )")
        );
        
        // ok we are now initialized
        $this->initialized = true;
    }
242555
protected function initFdsTable()
    {
        $this->fds = new Table($this->config['client_rows']);
        $this->fds->column('value', Table::TYPE_STRING, $this->config['client_size']);
        $this->fds->create();
    }
979360
public function createTable(Table $table)
    {
        $createFlags = AbstractPlatform::CREATE_INDEXES|AbstractPlatform::CREATE_FOREIGNKEYS;
        $this->_execSql($this->_platform->getCreateTableSQL($table, $createFlags));
    }
216384
public function createModel()
    {
        $file = '<?php'.$this->namespace.LF.LF;

        $file .= '/**'.LF;
        $file .= ' * Eloquent class to describe the '.$this->table.' table'.LF;
        $file .= ' *'.LF;
        $file .= ' * automatically generated by ModelGenerator.php'.LF;
        $file .= ' */'.LF;

        // a new class that extends the provided baseModel
        $file .= 'class '.$this->class.' extends '.$this->baseModel.LF;
        $file .= '{'.LF;

        // the name of the mysql table
        $file .= TAB.'protected $table = '.StringUtils::singleQuote($this->table).';'.LF.LF;

        // primary key defaults to "id"
        if ($this->primaryKey !== 'id') {
            $file .= TAB.'public $primaryKey = '.StringUtils::singleQuote($this->primaryKey).';'.LF.LF;
        }

        // timestamps defaults to true
        if (!$this->timestamps) {
            $file .= TAB.'public $timestamps = '.var_export($this->timestamps, true).';'.LF.LF;
        }

        // incrementing defaults to true
        if (!$this->incrementing) {
            $file .= TAB.'public $incrementing = '.var_export($this->incrementing, true).';'.LF.LF;
        }

        // all date fields
        if (!empty($this->dates)) {
            $file .= TAB.'public function getDates()'.LF;
            $file .= TAB.'{'.LF;
            $file .= TAB.TAB.'return array('.StringUtils::implodeAndQuote(', ', $this->dates).');'.LF;
            $file .= TAB.'}'.LF.LF;
        }

        // most fields are considered as fillable
        $wrap = TAB.'protected $fillable = array('.StringUtils::implodeAndQuote(', ', $this->fillable).');'.LF.LF;
        $file .= wordwrap($wrap, ModelGenerator::$lineWrap, LF.TAB.TAB);

        // except for the hidden ones
        if (!empty($this->hidden)) {
            $file .= TAB.'protected $hidden = array('.StringUtils::implodeAndQuote(', ', $this->hidden).');'.LF.LF;
        }

        // add all relations
        $file .= rtrim($this->relations).LF; // remove one LF from end

        // close the class
        $file .= '}'.LF;

        $this->fileContents = $file;
    }