Beispiel #1
0
 public function __construct($name, $nullable = false)
 {
     $this->setNullable($nullable);
     parent::__construct($name);
 }
Beispiel #2
0
 /**
  * @covers Zend\Db\Sql\Ddl\Column\Date::getExpressionData
  */
 public function testGetExpressionData()
 {
     $column = new Date('foo');
     $this->assertEquals(array(array('%s DATE %s %s', array('foo', 'NOT NULL', ''), array($column::TYPE_IDENTIFIER, $column::TYPE_LITERAL, $column::TYPE_LITERAL))), $column->getExpressionData());
 }
Beispiel #3
0
 public function getColumnDefinition($name, $type, $options)
 {
     switch ($type) {
         case 'string':
         case 'varchar':
             # Default options.
             $options = array_merge(['limit' => 255], $options);
             $column = new Ddl\Column\Varchar($name, $options['limit']);
             break;
         case 'char':
             # Default options.
             $options = array_merge(['limit' => 255], $options);
             $column = new Ddl\Column\Char($name, $options['limit']);
             break;
         case 'integer':
             $column = new Ddl\Column\Integer($name);
             break;
         case 'datetime':
             $column = new Column\DateTime($name);
             break;
         case 'text':
             $column = new Column\Text($name);
             break;
         case 'boolean':
             $column = new Column\Boolean($name);
             break;
         case 'date':
             $column = new Ddl\Column\Date($name);
             break;
         default:
             throw new Exception\RuntimeException(sprintf("Unknown column type '%s'", $type));
     }
     # Allow/disallow null, TRUE by default.
     $column->setNullable(!isset($options['null']) || !empty($options['null']));
     # Set default value.
     if (isset($options['default'])) {
         $column->setDefault($options['default']);
     }
     return $column;
 }