本文整理汇总了PHP中Doctrine\DBAL\Schema\Table类的典型用法代码示例。如果您正苦于以下问题:PHP Table类的具体用法?PHP Table怎么用?PHP Table使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Table类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: makeTableRepresentation
public function makeTableRepresentation(DBAL\Schema\Table $table)
{
$table->addColumn('id', 'string', ['length' => 100]);
$table->addColumn('datetime', 'datetime');
$table->addColumn('last_indexed', 'integer', ['length' => 50]);
$table->addIndex(['id', 'datetime']);
}
示例2: __construct
public function __construct(TableInformation $parent, \Doctrine\DBAL\Schema\Table $table, \Doctrine\DBAL\Schema\Column $column)
{
$this->table = $parent;
foreach ($table->getForeignKeys() as $foreign) {
if (in_array($column->getName(), $foreign->getColumns())) {
$foreign_columns = $foreign->getForeignColumns();
$this->foreignTable = $foreign->getForeignTableName();
$this->foreignColumn = reset($foreign_columns);
$this->isForeign = true;
}
}
if ($primary_key = $table->getPrimaryKey()) {
$this->isPrimary = in_array($column->getName(), $primary_key->getColumns());
}
$this->name = $column->getName();
$this->type = $column->getType()->getName();
$this->length = $column->getLength();
$this->precision = $column->getPrecision();
$this->default = $column->getDefault();
$this->isNotNull = $column->getNotnull();
$this->isUnsigned = $column->getUnsigned();
$this->isFixed = $column->getFixed();
$this->isAutoIncrement = $column->getAutoincrement();
$this->comment = $column->getComment();
if ($this->type === \Doctrine\DBAL\Types\Type::BLOB) {
$this->length = min($this->bytesFromIni('post_max_size'), $this->bytesFromIni('upload_max_filesize'));
}
}
示例3: testGenerateTableWithAutoincrement
public function testGenerateTableWithAutoincrement()
{
$table = new \Doctrine\DBAL\Schema\Table('autoinc_table');
$column = $table->addColumn('id', 'integer');
$column->setAutoincrement(true);
$this->assertEquals(array('CREATE TABLE autoinc_table (id SERIAL NOT NULL)'), $this->_platform->getCreateTableSQL($table));
}
示例4: addColumns
public function addColumns(\Doctrine\DBAL\Schema\Table $table, $columns)
{
foreach ($columns as $column) {
$table->addColumn($column['name'], $column['type'], $column['options']);
}
return $table;
}
示例5: testReservedColumnName
public function testReservedColumnName()
{
$table = new Table("TABLE");
$column = $table->addColumn('table', 'string');
$this->validator->acceptColumn($table, $column);
$this->assertEquals(array('Table TABLE column table keyword violations: MySQL'), $this->validator->getViolations());
}
示例6: acceptForeignKey
/**
* @param Table $localTable
* @param ForeignKeyConstraint $fkConstraint
*/
public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint)
{
// Append the foreign key constraints SQL
if ($this->_platform->supportsForeignKeyConstraints()) {
$this->_createFkConstraintQueries = array_merge($this->_createFkConstraintQueries, (array) $this->_platform->getCreateForeignKeySQL($fkConstraint, $localTable->getName()));
}
}
示例7: isTableNotIgnored
/**
* @param Table $table
* @return bool
*/
public function isTableNotIgnored(Table $table)
{
if (!$this->config->hasTableConfig($table->getName())) {
return true;
}
return !$this->config->getTableConfig($table->getName())->isTableIgnored();
}
示例8: createTable
private function createTable($name)
{
$table = new Schema\Table($this->tableName($name));
$table->addColumn('id', Type::INTEGER, ['autoincrement' => true, 'unsigned' => true]);
$table->setPrimaryKey(['id']);
return $table;
}
示例9: map
/**
* @param string $schema
* @param Table $table
* @param string $name
* @param FieldDefinition $definition
*/
public function map(string $schema, Table $table, string $name, FieldDefinition $definition)
{
$table->addColumn($name, 'float', ['notnull' => !$definition->isNullable(), 'default' => $definition->defaultValue(), 'unique' => $definition->options()['unique'] ?? false]);
if ($definition->options()['index'] ?? false) {
$table->addIndex([$name]);
}
}
示例10: makeTableRepresentation
public function makeTableRepresentation(DBAL\Schema\Table $table)
{
$table->addColumn('id', 'string', ['length' => 100]);
$table->addColumn('content', 'string', ['length' => $this->length]);
$table->addColumn('last_indexed', 'integer', ['length' => 50]);
$table->addIndex(['id', 'content']);
}
示例11: testCreateTemporaryTableNotAutoCommitTransaction
/**
* @group DDC-1337
* @return void
*/
public function testCreateTemporaryTableNotAutoCommitTransaction()
{
if ($this->_conn->getDatabasePlatform()->getName() == 'sqlanywhere' || $this->_conn->getDatabasePlatform()->getName() == 'oracle') {
$this->markTestSkipped("Test does not work on Oracle and SQL Anywhere.");
}
$platform = $this->_conn->getDatabasePlatform();
$columnDefinitions = array("id" => array("type" => Type::getType("integer"), "notnull" => true));
$tempTable = $platform->getTemporaryTableName("my_temporary");
$createTempTableSQL = $platform->getCreateTemporaryTableSnippetSQL() . ' ' . $tempTable . ' (' . $platform->getColumnDeclarationListSQL($columnDefinitions) . ')';
$table = new Table("nontemporary");
$table->addColumn("id", "integer");
$table->setPrimaryKey(array('id'));
foreach ($platform->getCreateTableSQL($table) as $sql) {
$this->_conn->executeQuery($sql);
}
$this->_conn->beginTransaction();
$this->_conn->insert("nontemporary", array("id" => 1));
$this->_conn->exec($createTempTableSQL);
$this->_conn->insert("nontemporary", array("id" => 2));
$this->_conn->rollback();
try {
$this->_conn->exec($platform->getDropTemporaryTableSQL($tempTable));
} catch (\Exception $e) {
}
$rows = $this->_conn->fetchAll('SELECT * FROM nontemporary');
$this->assertEquals(array(), $rows, "In an event of an error this result has one row, because of an implicit commit.");
}
示例12: exportCreateTable
/**
* Exports create table SQL.
*
* @return string
*/
protected function exportCreateTable()
{
$table = new Table(self::TABLE_NAME, array(), array(), array(), false, array());
$table->addColumn('id', 'string', array('length' => 2, 'notnull' => true));
$table->setPrimaryKey(array('id'));
$table->addColumn('value', 'string', array('length' => 64));
return array_pop($this->getConnection()->getDatabasePlatform()->getCreateTableSQL($table, AbstractPlatform::CREATE_INDEXES)) . ';' . PHP_EOL;
}
示例13: map
/**
* @param string $schema
* @param Table $table
* @param string $name
* @param FieldDefinition $definition
*
* @throws DoctrineStorageException
*/
public function map(string $schema, Table $table, string $name, FieldDefinition $definition)
{
if (!$definition instanceof AssociationFieldDefinition) {
throw DoctrineStorageException::invalidDefinition(AssociationFieldDefinition::class, $definition);
}
$table->addColumn($name, 'guid', ['notnull' => !$definition->isNullable(), 'default' => $definition->defaultValue(), 'length' => $definition->options()['length'] ?? null, 'unique' => $definition->options()['unique'] ?? false]);
$table->addForeignKeyConstraint($this->tableName($schema, $definition->typeSchema()->name()), [$name], ['id']);
}
示例14: buildTable
/**
* Get the table's schema object.
*
* @param Schema $schema
* @param string $tableName
*
* @return \Doctrine\DBAL\Schema\Table
*/
public function buildTable(Schema $schema, $tableName)
{
$this->table = $schema->createTable($tableName);
$this->tableName = $this->table->getName();
$this->addColumns();
$this->addIndexes();
$this->setPrimaryKey();
return $this->table;
}
示例15: addForeignKey
/**
* @param DBALTable $KeyTarget Foreign Key (Column: KeySource Name)
* @param DBALTable $KeySource Foreign Data (Column: Id)
*/
public function addForeignKey(DBALTable &$KeyTarget, DBALTable $KeySource)
{
if (!$this->Database->hasColumn($KeyTarget->getName(), $KeySource->getName())) {
$KeyTarget->addColumn($KeySource->getName(), 'bigint');
if ($this->Database->getPlatform()->supportsForeignKeyConstraints()) {
$KeyTarget->addForeignKeyConstraint($KeySource, array($KeySource->getName()), array('Id'));
}
}
}