本文整理汇总了PHP中Illuminate\Database\Schema\Builder::getConnection方法的典型用法代码示例。如果您正苦于以下问题:PHP Builder::getConnection方法的具体用法?PHP Builder::getConnection怎么用?PHP Builder::getConnection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\Schema\Builder
的用法示例。
在下文中一共展示了Builder::getConnection方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateColumn
/**
* Update the field type column to the table.
*
* @param Blueprint $table
* @param AssignmentInterface $assignment
*/
public function updateColumn(Blueprint $table, AssignmentInterface $assignment)
{
// Skip if no column type.
if (!$this->fieldType->getColumnType()) {
return;
}
// Skip if the column doesn't exists.
if (!$this->schema->hasColumn($table->getTable(), $this->fieldType->getColumnName())) {
return;
}
/**
* Update the column to the table.
*
* @var Blueprint|Fluent $column
*/
$column = call_user_func_array([$table, $this->fieldType->getColumnType()], array_filter([$this->fieldType->getColumnName(), $this->fieldType->getColumnLength()]));
$column->nullable(!$assignment->isTranslatable() ? !$assignment->isRequired() : true)->change();
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.
* Otherwise, drop the unique index.
*/
$connection = $this->schema->getConnection();
$manager = $connection->getDoctrineSchemaManager();
$doctrine = $manager->listTableDetails($connection->getTablePrefix() . $table->getTable());
// The unique index name.
$unique = md5('unique_' . $this->fieldType->getColumnName());
/**
* If the assignment is unique and not translatable
* and the table does not already have the given the
* given table index then go ahead and add it.
*/
if ($assignment->isUnique() && !$assignment->isTranslatable() && !$doctrine->hasIndex($unique)) {
$table->unique($this->fieldType->getColumnName(), $unique);
}
/**
* If the assignment is NOT unique and not translatable
* and the table DOES have the given table index
* then we need to remove.
*/
if (!$assignment->isUnique() && !$assignment->isTranslatable() && $doctrine->hasIndex($unique)) {
$column->dropIndex(md5('unique_' . $this->fieldType->getColumnName()));
}
}
示例2: getConnection
/**
* Get the database connection instance.
*
* @return \Illuminate\Database\Connection
* @static
*/
public static function getConnection()
{
return \Illuminate\Database\Schema\Builder::getConnection();
}
示例3: getConnection
/**
* Get the database connection instance.
*
* @return \Illuminate\Database\Connection
*/
public function getConnection()
{
return static::$schema->getConnection();
}
示例4: __construct
/**
* @param ApplicationContract $app
* @param BaseBuilder $base
*/
public function __construct(ApplicationContract $app, BaseBuilder $base)
{
parent::__construct($base->getConnection());
}