Exemplo n.º 1
0
 public function createEnumColumn($defaultValues, $defaultValue)
 {
     $column = new Column();
     $column->setType(PropelTypes::ENUM);
     $column->setValueSet($defaultValues);
     $column->setDefaultValue($defaultValue);
     return $column;
 }
 public static function getDefaultValueStringProvider()
 {
     $col1 = new Column('Bar');
     $col1->setDomain(new Domain('VARCHAR'));
     $col1->setDefaultValue(new ColumnDefaultValue('abc', ColumnDefaultValue::TYPE_VALUE));
     $val1 = "'abc'";
     $col2 = new Column('Bar');
     $col2->setDomain(new Domain('INTEGER'));
     $col2->setDefaultValue(new ColumnDefaultValue(1234, ColumnDefaultValue::TYPE_VALUE));
     $val2 = "1234";
     $col3 = new Column('Bar');
     $col3->setDomain(new Domain('DATE'));
     $col3->setDefaultValue(new ColumnDefaultValue('0000-00-00', ColumnDefaultValue::TYPE_VALUE));
     $val3 = "NULL";
     return array(array($col1, $val1), array($col2, $val2), array($col3, $val3));
 }
Exemplo n.º 3
0
 /**
  * Obtiene el detalle de columnas de la tabla o vista actual
  * @return Array
  */
 public function checkColumnDetail()
 {
     $sql = "select ut.column_name, data_type, data_length, nullable, data_default, comments " . "from user_tab_columns ut inner join user_col_comments uc " . "on ut.table_name = uc.table_name " . "and ut.column_name = uc.column_name " . "where ut.table_name = upper(:v_table)";
     $stmt = oci_parse($this->getConnection(), $sql);
     oci_bind_by_name($stmt, ":v_table", $this->objectName);
     if (!@oci_execute($stmt)) {
         $e = oci_error();
         $this->setMensaje("Error al obtener el detalle de las columnas de la tabla o vista '{$this->objectName}' - {$e['message']}");
         $this->setEstado(false);
     }
     while ($row = oci_fetch_array($stmt, OCI_ASSOC | OCI_RETURN_NULLS)) {
         $column = new Column();
         $column->setColumnName($row['COLUMN_NAME']);
         $column->setDataType($row['DATA_TYPE']);
         $column->setDataLength($row['DATA_LENGTH']);
         $column->setIsNullable($row['NULLABLE']);
         $column->setDefaultValue($row['DATA_DEFAULT']);
         $column->setComment($row['COMMENTS']);
         $this->aColumns[] = $column;
     }
     return $this->aColumns;
 }
 public function createMigrationTable($datasource)
 {
     $platform = $this->getPlatform($datasource);
     // modelize the table
     $database = new Database($datasource);
     $database->setPlatform($platform);
     $table = new Table($this->getMigrationTable());
     $database->addTable($table);
     $column = new Column('version');
     $column->getDomain()->copy($platform->getDomainForType('INTEGER'));
     $column->setDefaultValue(0);
     $table->addColumn($column);
     // insert the table into the database
     $statements = $platform->getAddTableDDL($table);
     $pdo = $this->getPdoConnection($datasource);
     $res = PropelSQLParser::executeString($statements, $pdo);
     if (!$res) {
         throw new Exception(sprintf('Unable to create migration table in datasource "%s"', $datasource));
     }
 }
 public function providerForTestGetModifyColumnRemoveDefaultValueDDL()
 {
     $t1 = new Table('test');
     $c1 = new Column();
     $c1->setName('test');
     $c1->getDomain()->setType('INTEGER');
     $c1->setDefaultValue(0);
     $t1->addColumn($c1);
     $t2 = new Table('test');
     $c2 = new Column();
     $c2->setName('test');
     $c2->getDomain()->setType('INTEGER');
     $t2->addColumn($c2);
     return array(array(PropelColumnComparator::computeDiff($c1, $c2)));
 }