getTablePrefix() public method

Get the table prefix for the connection.
public getTablePrefix ( ) : string
return string
示例#1
0
 /**
  * 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);
     }
 }
 /**
  * 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
0
 /**
  * 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
0
 /**
  * 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;
 }