Esempio n. 1
0
 public function testComplex()
 {
     $column = new Column('title', 'string', ['null' => true, 'default' => '', 'length' => 255, 'after' => 'id']);
     $this->assertEquals('title', $column->getName());
     $this->assertEquals('string', $column->getType());
     $this->assertTrue($column->allowNull());
     $this->assertEquals('', $column->getDefault());
     $this->assertEquals(255, $column->getLength());
     $this->assertEquals(255, $column->getLength(100));
     $this->assertNull($column->getDecimals());
     $this->assertEquals(2, $column->getDecimals(2));
     $this->assertTrue($column->isSigned());
     $this->assertFalse($column->isAutoincrement());
     $this->assertFalse($column->isFirst());
     $this->assertEquals('id', $column->getAfter());
 }
Esempio n. 2
0
 private function createColumnDefault(Column $column)
 {
     if ($column->allowNull() && $column->getDefault() === null) {
         return ' DEFAULT NULL';
     }
     if ($column->getDefault() !== null) {
         $default = ' DEFAULT ';
         if ($column->getType() == Column::TYPE_INTEGER) {
             return $default .= $column->getDefault();
         }
         if ($column->getType() == Column::TYPE_BOOLEAN) {
             return $default .= intval($column->getDefault());
         }
         return $default .= "'" . $column->getDefault() . "'";
     }
     return '';
 }