本文整理汇总了PHP中Doctrine\DBAL\Schema\Table::addOption方法的典型用法代码示例。如果您正苦于以下问题:PHP Table::addOption方法的具体用法?PHP Table::addOption怎么用?PHP Table::addOption使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\DBAL\Schema\Table
的用法示例。
在下文中一共展示了Table::addOption方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildTable
/**
* Get the table's schema object.
*
* @param Schema $schema
* @param string $tableName
* @param string $aliasName
*
* @return \Doctrine\DBAL\Schema\Table
*/
public function buildTable(Schema $schema, $tableName, $aliasName)
{
$this->table = $schema->createTable($tableName);
$this->table->addOption('alias', $aliasName);
$this->aliasName = $aliasName;
$this->tableName = $this->table->getName();
$this->addColumns();
$this->addIndexes();
$this->setPrimaryKey();
return $this->table;
}
示例2: buildTable
/**
* Get the table's schema object.
*
* @param Schema $schema
* @param string $aliasName
* @param string $charset
* @param string $collate
*
* @return \Doctrine\DBAL\Schema\Table
*/
public function buildTable(Schema $schema, $aliasName, $charset, $collate)
{
$tableName = $this->tablePrefix . $aliasName;
$this->table = $schema->createTable($tableName);
$this->table->addOption('alias', $aliasName);
$this->table->addOption('charset', $charset);
$this->table->addOption('collate', $collate);
$this->aliasName = $aliasName;
$this->tableName = $this->table->getName();
$this->addColumns();
$this->addIndexes();
$this->setPrimaryKey();
$this->addForeignKeyConstraints();
return $this->table;
}
示例3: enableDataAudit
/**
* @param Table $taskTable
*/
protected function enableDataAudit(Table $taskTable)
{
$taskTable->addOption(OroOptions::KEY, ['dataaudit' => ['auditable' => true]]);
$taskTable->getColumn('subject')->setOptions([OroOptions::KEY => ['dataaudit' => ['auditable' => true]]]);
$taskTable->getColumn('description')->setOptions([OroOptions::KEY => ['dataaudit' => ['auditable' => true]]]);
$taskTable->getColumn('due_date')->setOptions([OroOptions::KEY => [ExtendOptionsManager::FIELD_NAME_OPTION => 'dueDate', 'dataaudit' => ['auditable' => true]]]);
$taskTable->getColumn('task_priority_name')->setOptions([OroOptions::KEY => [ExtendOptionsManager::FIELD_NAME_OPTION => 'taskPriority', 'dataaudit' => ['auditable' => true]]]);
$taskTable->getColumn('owner_id')->setOptions([OroOptions::KEY => [ExtendOptionsManager::FIELD_NAME_OPTION => 'owner', 'dataaudit' => ['auditable' => true]]]);
}
示例4: enableDataAudit
/**
* @param Table $table
*/
protected function enableDataAudit(Table $table)
{
$table->addOption(OroOptions::KEY, ['dataaudit' => ['auditable' => true]]);
$table->getColumn('title')->setOptions([OroOptions::KEY => ['dataaudit' => ['auditable' => true]]]);
$table->getColumn('description')->setOptions([OroOptions::KEY => ['dataaudit' => ['auditable' => true]]]);
$table->getColumn('start_at')->setOptions([OroOptions::KEY => [ExtendOptionsManager::FIELD_NAME_OPTION => 'start', 'dataaudit' => ['auditable' => true]]]);
$table->getColumn('end_at')->setOptions([OroOptions::KEY => [ExtendOptionsManager::FIELD_NAME_OPTION => 'end', 'dataaudit' => ['auditable' => true]]]);
$table->getColumn('calendar_id')->setOptions([OroOptions::KEY => [ExtendOptionsManager::FIELD_NAME_OPTION => 'calendar', 'dataaudit' => ['auditable' => true]]]);
$table->getColumn('all_day')->setOptions([OroOptions::KEY => [ExtendOptionsManager::FIELD_NAME_OPTION => 'allDay', 'dataaudit' => ['auditable' => true]]]);
}
示例5: testFulltextIndex
public function testFulltextIndex()
{
$table = new Table('fulltext_index');
$table->addColumn('text', 'text');
$table->addIndex(array('text'), 'f_index');
$table->addOption('engine', 'MyISAM');
$index = $table->getIndex('f_index');
$index->addFlag('fulltext');
$this->_sm->dropAndCreateTable($table);
$indexes = $this->_sm->listTableIndexes('fulltext_index');
$this->assertArrayHasKey('f_index', $indexes);
$this->assertTrue($indexes['f_index']->hasFlag('fulltext'));
}
示例6: testColumnCollation
public function testColumnCollation()
{
$table = new Table('test_collation');
$table->addOption('collate', $collation = 'utf8_unicode_ci');
$table->addColumn('id', 'integer');
$table->addColumn('text', 'text');
$table->addColumn('foo', 'text')->setPlatformOption('collation', 'utf8_swedish_ci');
$table->addColumn('bar', 'text')->setPlatformOption('collation', 'utf8_general_ci');
$this->_sm->dropAndCreateTable($table);
$columns = $this->_sm->listTableColumns('test_collation');
$this->assertArrayNotHasKey('collation', $columns['id']->getPlatformOptions());
$this->assertEquals('utf8_unicode_ci', $columns['text']->getPlatformOption('collation'));
$this->assertEquals('utf8_swedish_ci', $columns['foo']->getPlatformOption('collation'));
$this->assertEquals('utf8_general_ci', $columns['bar']->getPlatformOption('collation'));
}
示例7: getAlterTableSQL
/**
* {@inheritDoc}
*/
public function getAlterTableSQL(TableDiff $diff)
{
$sql = $this->getSimpleAlterTableSQL($diff);
if (false !== $sql) {
return $sql;
}
$fromTable = $diff->fromTable;
if (!$fromTable instanceof Table) {
throw new DBALException('Sqlite platform requires for alter table the table diff with reference to original table schema');
}
$table = clone $fromTable;
$columns = array();
$oldColumnNames = array();
$newColumnNames = array();
$columnSql = array();
foreach ($table->getColumns() as $columnName => $column) {
$columnName = strtolower($columnName);
$columns[$columnName] = $column;
$oldColumnNames[$columnName] = $newColumnNames[$columnName] = $column->getQuotedName($this);
}
foreach ($diff->removedColumns as $columnName => $column) {
if ($this->onSchemaAlterTableRemoveColumn($column, $diff, $columnSql)) {
continue;
}
$columnName = strtolower($columnName);
if (isset($columns[$columnName])) {
unset($columns[$columnName]);
unset($oldColumnNames[$columnName]);
unset($newColumnNames[$columnName]);
}
}
foreach ($diff->renamedColumns as $oldColumnName => $column) {
if ($this->onSchemaAlterTableRenameColumn($oldColumnName, $column, $diff, $columnSql)) {
continue;
}
$oldColumnName = strtolower($oldColumnName);
if (isset($columns[$oldColumnName])) {
unset($columns[$oldColumnName]);
}
$columns[strtolower($column->getName())] = $column;
if (isset($newColumnNames[$oldColumnName])) {
$newColumnNames[$oldColumnName] = $column->getQuotedName($this);
}
}
foreach ($diff->changedColumns as $oldColumnName => $columnDiff) {
if ($this->onSchemaAlterTableChangeColumn($columnDiff, $diff, $columnSql)) {
continue;
}
if (isset($columns[$oldColumnName])) {
unset($columns[$oldColumnName]);
}
$columns[strtolower($columnDiff->column->getName())] = $columnDiff->column;
if (isset($newColumnNames[$oldColumnName])) {
$newColumnNames[$oldColumnName] = $columnDiff->column->getQuotedName($this);
}
}
foreach ($diff->addedColumns as $columnName => $column) {
if ($this->onSchemaAlterTableAddColumn($column, $diff, $columnSql)) {
continue;
}
$columns[strtolower($columnName)] = $column;
}
$sql = array();
$tableSql = array();
if (!$this->onSchemaAlterTable($diff, $tableSql)) {
$dataTable = new Table('__temp__' . $table->getName());
$newTable = new Table($table->getQuotedName($this), $columns, $this->getPrimaryIndexInAlteredTable($diff), $this->getForeignKeysInAlteredTable($diff), 0, $table->getOptions());
$newTable->addOption('alter', true);
$sql = $this->getPreAlterTableIndexForeignKeySQL($diff);
//$sql = array_merge($sql, $this->getCreateTableSQL($dataTable, 0));
$sql[] = sprintf('CREATE TEMPORARY TABLE %s AS SELECT %s FROM %s', $dataTable->getQuotedName($this), implode(', ', $oldColumnNames), $table->getQuotedName($this));
$sql[] = $this->getDropTableSQL($fromTable);
$sql = array_merge($sql, $this->getCreateTableSQL($newTable));
$sql[] = sprintf('INSERT INTO %s (%s) SELECT %s FROM %s', $newTable->getQuotedName($this), implode(', ', $newColumnNames), implode(', ', $oldColumnNames), $dataTable->getQuotedName($this));
$sql[] = $this->getDropTableSQL($dataTable);
if ($diff->newName && $diff->newName != $diff->name) {
$renamedTable = $diff->getNewName();
$sql[] = 'ALTER TABLE ' . $newTable->getQuotedName($this) . ' RENAME TO ' . $renamedTable->getQuotedName($this);
}
$sql = array_merge($sql, $this->getPostAlterTableIndexForeignKeySQL($diff));
}
return array_merge($sql, $tableSql, $columnSql);
}
示例8: testBuilderOptions
public function testBuilderOptions()
{
$table = new Table("foo");
$table->addOption("foo", "bar");
$this->assertTrue($table->hasOption("foo"));
$this->assertEquals("bar", $table->getOption("foo"));
}
示例9: testCreateTableWithFulltextIndex
public function testCreateTableWithFulltextIndex()
{
$table = new Table('fulltext_table');
$table->addOption('engine', 'MyISAM');
$table->addColumn('text', 'text');
$table->addIndex(array('text'), 'fulltext_text');
$index = $table->getIndex('fulltext_text');
$index->addFlag('fulltext');
$sql = $this->_platform->getCreateTableSQL($table);
$this->assertEquals(array('CREATE TABLE fulltext_table (text LONGTEXT NOT NULL, FULLTEXT INDEX fulltext_text (text)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = MyISAM'), $sql);
}
示例10: collate
/**
* Sets the collate option
*
* @param string $collate collate
* @return $this
*/
public function collate($collate)
{
$this->table->addOption('collate', $collate);
return $this;
}
示例11: testDoesNotPropagateForeignKeyAlterationForNonSupportingEngines
public function testDoesNotPropagateForeignKeyAlterationForNonSupportingEngines()
{
$table = new Table("foreign_table");
$table->addColumn('id', 'integer');
$table->addColumn('fk_id', 'integer');
$table->addForeignKeyConstraint('foreign_table', array('fk_id'), array('id'));
$table->setPrimaryKey(array('id'));
$table->addOption('engine', 'MyISAM');
$addedForeignKeys = array(new ForeignKeyConstraint(array('fk_id'), 'foo', array('id'), 'fk_add'));
$changedForeignKeys = array(new ForeignKeyConstraint(array('fk_id'), 'bar', array('id'), 'fk_change'));
$removedForeignKeys = array(new ForeignKeyConstraint(array('fk_id'), 'baz', array('id'), 'fk_remove'));
$tableDiff = new TableDiff('foreign_table');
$tableDiff->fromTable = $table;
$tableDiff->addedForeignKeys = $addedForeignKeys;
$tableDiff->changedForeignKeys = $changedForeignKeys;
$tableDiff->removedForeignKeys = $removedForeignKeys;
$this->assertEmpty($this->_platform->getAlterTableSQL($tableDiff));
$table->addOption('engine', 'InnoDB');
$tableDiff = new TableDiff('foreign_table');
$tableDiff->fromTable = $table;
$tableDiff->addedForeignKeys = $addedForeignKeys;
$tableDiff->changedForeignKeys = $changedForeignKeys;
$tableDiff->removedForeignKeys = $removedForeignKeys;
$this->assertSame(array('ALTER TABLE foreign_table DROP FOREIGN KEY fk_remove', 'ALTER TABLE foreign_table DROP FOREIGN KEY fk_change', 'ALTER TABLE foreign_table ADD CONSTRAINT fk_add FOREIGN KEY (fk_id) REFERENCES foo (id)', 'ALTER TABLE foreign_table ADD CONSTRAINT fk_change FOREIGN KEY (fk_id) REFERENCES bar (id)'), $this->_platform->getAlterTableSQL($tableDiff));
}
示例12: parseTableOpts
protected static function parseTableOpts(Schema $schema, Table $table, SimpleXMLElement $xOptParent, AbstractPlatform $platform)
{
$opts = static::getOptArray($xOptParent, $platform);
foreach ($opts as $name => $value) {
$table->addOption($name, $value);
}
}