本文整理汇总了PHP中Illuminate\Database\Connection::getTablePrefix方法的典型用法代码示例。如果您正苦于以下问题:PHP Connection::getTablePrefix方法的具体用法?PHP Connection::getTablePrefix怎么用?PHP Connection::getTablePrefix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\Connection
的用法示例。
在下文中一共展示了Connection::getTablePrefix方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateTableFromMetadata
/**
* Generate a table from metadata.
*
* @param table \Doctrine\DBAL\Schema\Schema
* @param \ProAI\Datamapper\Metadata\Definitions\Table $tableMetadata
* @return void
*/
protected function generateTableFromMetadata($schema, TableDefinition $tableMetadata)
{
$primaryKeys = [];
$uniqueIndexes = [];
$indexes = [];
$table = $schema->createTable($this->connection->getTablePrefix() . $tableMetadata['name']);
foreach ($tableMetadata['columns'] as $columnMetadata) {
$columnMetadata = $this->getDoctrineColumnAliases($columnMetadata);
// add column
$options = $this->getDoctrineColumnOptions($columnMetadata);
$table->addColumn($columnMetadata['name'], $columnMetadata['type'], $options);
// add primary keys, unique indexes and indexes
if (!empty($columnMetadata['primary'])) {
$primaryKeys[] = $columnMetadata['name'];
}
if (!empty($columnMetadata['unique'])) {
$uniqueIndexes[] = $columnMetadata['name'];
}
if (!empty($columnMetadata['index'])) {
$indexes[] = $columnMetadata['name'];
}
}
// add primary keys, unique indexes and indexes
if (!empty($primaryKeys)) {
$table->setPrimaryKey($primaryKeys);
}
if (!empty($uniqueIndexes)) {
$table->addUniqueIndex($uniqueIndexes);
}
if (!empty($indexes)) {
$table->addIndex($indexes);
}
}
示例2: dropAutoIncrementObjects
/**
* drop sequence and triggers if exists, autoincrement objects
*
* @param string $table
* @return null
*/
public function dropAutoIncrementObjects($table)
{
// drop sequence and trigger object
$prefix = $this->connection->getTablePrefix();
// get the actual primary column name from table
$col = $this->getPrimaryKey($prefix . $table);
// if primary key col is set, drop auto increment objects
if (isset($col) and !empty($col)) {
// drop sequence for auto increment
$sequenceName = $this->createObjectName($prefix, $table, $col, 'seq');
$this->sequence->drop($sequenceName);
// drop trigger for auto increment work around
$triggerName = $this->createObjectName($prefix, $table, $col, 'trg');
$this->trigger->drop($triggerName);
}
}
示例3: getColumnListing
/**
* Get the column listing for a given table.
*
* @param string $table
* @return array
*/
public function getColumnListing($table)
{
$table = $this->connection->getTablePrefix() . $table;
$results = $this->connection->select($this->grammar->compileColumnExists($table));
return $this->connection->getPostProcessor()->processColumnListing($results);
}
示例4: hasTable
/**
* Determine if the given table exists.
*
* @param string $table
* @return bool
*/
public function hasTable($table)
{
$sql = $this->grammar->compileTableExists();
$table = $this->connection->getTablePrefix() . $table;
return count($this->connection->select($sql, array($table))) > 0;
}