Eli Y
Eli Y

Reputation: 907

PhalconPHP create tables dynamically

Using PhalconPHP, is it possible to create a table in a database using an ORM model with metadata in comments? For example, using symphony one can achive what I want like this: http://symfony.com/doc/current/book/doctrine.html

Upvotes: 1

Views: 708

Answers (1)

Eli Y
Eli Y

Reputation: 907

so the solution I've found is this

$connection->createTable("robots", null, array(
      "columns" => array(
            new Column("id", array(
                "type"  => Column::TYPE_INTEGER,
                "size"  => 10,
                "notNull"       => true,
                "autoIncrement" => true,
            )),
            new Column("name", array(
                "type"    => Column::TYPE_VARCHAR,
                "size"    => 70,
                "notNull" => true,
            )),
            new Column("year", array(
                "type"    => Column::TYPE_INTEGER,
                "size"    => 11,
                "notNull" => true,
            ))
      ),
      "indexes" => array(
            new Index("PRIMARY", array("id"))
      )
));

hope it will be help to someone :)

Upvotes: 3

Related Questions