本文整理匯總了PHP中Illuminate\Database\Schema\Blueprint::getTable方法的典型用法代碼示例。如果您正苦於以下問題:PHP Blueprint::getTable方法的具體用法?PHP Blueprint::getTable怎麽用?PHP Blueprint::getTable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Illuminate\Database\Schema\Blueprint
的用法示例。
在下文中一共展示了Blueprint::getTable方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: add
/**
* Add a foreign key to table and defer its foreign key creation.
*
* @param string $fk
* @param string $column
* @param string $keyName
* @param string $onDelete
* @param string $onUpdate
* @return \Illuminate\Support\Fluent
*/
public function add($fk, $column = null, $keyName = null, $onDelete = null, $onUpdate = null)
{
$baseFk = $this->baseFk($fk);
$column = $column ?: $baseFk->defaultColumn();
static::$foreignKeys[] = ['column' => $column ?: $this->column, 'key_name' => $keyName ?: $this->keyName, 'table' => $this->table->getTable(), 'reference_table' => $baseFk->referenceTable(), 'primary_key' => $baseFk->primaryKey, 'on_delete' => $onDelete ?: $this->onDelete ?: $baseFk->onDelete, 'on_update' => $onUpdate ?: $this->onUpdate ?: $baseFk->onUpdate];
return $baseFk->createFkColumn($column);
}
示例2: build
/**
* Execute the blueprint to build / modify the table.
*
* @param \Cooperl\Database\DB2\Schema\Blueprint $blueprint
* @return void
*/
protected function build(Blueprint $blueprint)
{
$schemaTable = explode(".", $blueprint->getTable());
if (count($schemaTable) > 1) {
$this->connection->setCurrentSchema($schemaTable[0]);
}
$blueprint->build($this->connection, $this->grammar);
$this->connection->resetCurrentSchema();
}
示例3: addColumn
/**
* Add the field type column.
*
* @param Blueprint $table
* @param AssignmentInterface $assignment
*/
public function addColumn(Blueprint $table, AssignmentInterface $assignment)
{
// Skip if the column already exists.
if ($this->schema->hasColumn($table->getTable(), $this->fieldType->getColumnName() . '_id')) {
return;
}
$table->string($this->fieldType->getColumnName() . '_type')->nullable(!$assignment->isRequired());
$table->integer($this->fieldType->getColumnName() . '_id')->nullable(!$assignment->isRequired());
if ($assignment->isUnique() && $assignment->isTranslatable()) {
$table->unique([$this->fieldType->getColumnName() . '_type', $this->fieldType->getColumnName() . '_id']);
}
}
示例4: addColumn
/**
* @param Blueprint $table
* @param AssignmentInterface $assignment
*/
public function addColumn(Blueprint $table, AssignmentInterface $assignment)
{
// Skip if the column already exists.
if ($this->schema->hasColumn($table->getTable(), $this->fieldType->getColumnName())) {
return;
}
/**
* Add the column to the table.
*
* @var Blueprint|Fluent $column
*/
$column = $table->{$this->fieldType->getColumnType()}($this->fieldType->getColumnName(), 11, array_get($this->fieldType->getConfig(), 'decimals', 2))->nullable(!$assignment->isTranslatable() ? !$assignment->isRequired() : true);
if (!str_contains($this->fieldType->getColumnType(), ['text', 'blob'])) {
$column->default(array_get($this->fieldType->getConfig(), 'default_value'));
}
// Mark the column unique if desired and not translatable.
if ($assignment->isUnique() && !$assignment->isTranslatable()) {
$table->unique($this->fieldType->getColumnName());
}
}
示例5: getDoctrineTableDiff
/**
* Create an empty Doctrine DBAL TableDiff from the Blueprint.
*
* @param \Illuminate\Database\Schema\Blueprint $blueprint
* @param \Doctrine\DBAL\Schema\AbstractSchemaManager $schema
* @return \Doctrine\DBAL\Schema\TableDiff
*/
protected function getDoctrineTableDiff(Blueprint $blueprint, SchemaManager $schema)
{
$table = $this->getTablePrefix() . $blueprint->getTable();
$tableDiff = new TableDiff($table);
$tableDiff->fromTable = $schema->listTableDetails($table);
return $tableDiff;
}
示例6: compileDropPrimary
/**
* Compile a drop primary key command.
*
* @param \Illuminate\Database\Schema\Blueprint $blueprint
* @param \Illuminate\Support\Fluent $command
* @return string
*/
public function compileDropPrimary(Blueprint $blueprint, Fluent $command)
{
$table = $blueprint->getTable();
$index = $this->wrap("{$table}_pkey");
return 'alter table ' . $this->wrapTable($blueprint) . " drop constraint {$index}";
}
示例7: compileDropPrimary
/**
* Compile a drop primary key command.
*
* @param \Illuminate\Database\Schema\Blueprint $blueprint
* @param \Illuminate\Support\Fluent $command
* @return string
*/
public function compileDropPrimary(Blueprint $blueprint, Fluent $command)
{
$table = $blueprint->getTable();
$table = $this->wrapTable($blueprint);
return "alter table {$table} drop constraint {$command->index}";
}
示例8: compileDropIfExists
/**
* Compile a drop table (if exists) command.
*
* @param \Illuminate\Database\Schema\Blueprint $blueprint
* @param \Illuminate\Support\Fluent $command
* @return string
*/
public function compileDropIfExists(Blueprint $blueprint, Fluent $command)
{
return 'if exists (select * from INFORMATION_SCHEMA.TABLES where TABLE_NAME = \'' . $blueprint->getTable() . '\') drop table [' . $blueprint->getTable() . ']';
}
示例9: getChangedDiff
/**
* Get the Doctrine table difference for the given changes.
*
* @param \Illuminate\Database\Schema\Blueprint $blueprint
* @param \Doctrine\DBAL\Schema\AbstractSchemaManager $schema
* @return \Doctrine\DBAL\Schema\TableDiff|bool
*/
protected function getChangedDiff(Blueprint $blueprint, SchemaManager $schema)
{
$table = $schema->listTableDetails($this->getTablePrefix() . $blueprint->getTable());
return (new Comparator())->diffTable($table, $this->getTableWithColumnChanges($blueprint, $table));
}
示例10: modifyIncrement
/**
* Get the SQL for an auto-increment column modifier.
*
* @param \Illuminate\Database\Schema\Blueprint $blueprint
* @param \Illuminate\Support\Fluent $column
* @return string|null
*/
protected function modifyIncrement(Blueprint $blueprint, Fluent $column)
{
if (in_array($column->type, $this->serials) && $column->autoIncrement) {
return ' as identity constraint ' . $blueprint->getTable() . '_' . $column->name . '_primary primary key';
}
}
示例11: dropColumn
/**
* Drop the field type column from the table.
*
* @param Blueprint $table
*/
public function dropColumn(Blueprint $table)
{
// Skip if no column type.
if (!$this->fieldType->getColumnType()) {
return;
}
// Skip if the column doesn't exist.
if (!$this->schema->hasColumn($table->getTable(), $this->fieldType->getColumnName())) {
return;
}
// Drop dat 'ole column.
$table->dropColumn($this->fieldType->getColumnName());
}
示例12: compileDropIfExists
/**
* Compile a drop table (if exists) command.
*
* @param \Illuminate\Database\Schema\Blueprint $blueprint
* @param \Illuminate\Support\Fluent $command
* @return string
*/
public function compileDropIfExists(Blueprint $blueprint, Fluent $command)
{
$table = "'" . str_replace("'", "''", $this->getTablePrefix() . $blueprint->getTable()) . "'";
return 'if exists (select * from INFORMATION_SCHEMA.TABLES where TABLE_NAME = ' . $table . ') drop table ' . $this->wrapTable($blueprint);
}
示例13: restoreColumn
/**
* Restore the field type column to cache.
*
* @param Blueprint $table
*/
public function restoreColumn(Blueprint $table)
{
// Skip if no column type.
if (!$this->fieldType->getColumnType()) {
return;
}
// Skip if the column doesn't exist.
if (!$this->schema->hasColumn($table->getTable(), $this->fieldType->getColumnName())) {
return;
}
// Translatable or no?
$translatable = ends_with($table->getTable(), '_translations');
// Restore the data.
$results = $this->cache->get(__CLASS__ . $this->fieldType->getColumnName());
foreach ($results as $result) {
$result = (array) $result;
$this->connection->table($table->getTable())->where($translatable ? 'entry_id' : 'id', array_pull($result, 'id'))->update($result);
}
$this->cache->forget(__CLASS__ . $this->fieldType->getColumnName());
}
示例14: dropColumn
/**
* Drop the pivot table.
*
* @param Blueprint $table
*/
public function dropColumn(Blueprint $table)
{
$this->schema->dropIfExists($table->getTable() . '_' . $this->fieldType->getField());
}