Example #1
0
 public function setUp()
 {
     parent::setUp();
     $q = new DropTableQuery('users');
     $q->ifExists();
     $this->assertQuery($q);
     $q = new CreateTableQuery('users');
     $q->column('id')->integer()->primary()->autoIncrement();
     $q->column('first_name')->varchar(32);
     $q->column('last_name')->varchar(16);
     $q->column('age')->tinyint(3)->unsigned()->null();
     $q->column('phone')->varchar(24)->null();
     $q->column('email')->varchar(128)->notNull();
     $q->column('confirmed')->boolean()->default(false);
     $q->column('types')->set('student', 'teacher');
     $q->column('remark')->text();
     $q->index(['first_name', 'last_name'])->name('username_idx');
     $this->assertQuery($q);
 }
    public function testCreateTableWithSimpleIndex()
    {
        $q = new CreateTableQuery('groups');
        $q->column('id')->integer();
        $q->column('name')->varchar(20);
        $q->column('content')->text();
        $q->column('blob_content')->blob();
        $q->index(['name'])->name('name_idx')->using('BTREE');
        $this->assertSql('CREATE TABLE `groups`(
`id` int,
`name` varchar(20),
`content` text,
`blob_content` blob,
INDEX `name_idx` USING BTREE (`name`)
)', $q);
        $this->assertQuery($q);
    }