Bolt\Storage\Database\Schema\Manager::getInstalledTables PHP Method

getInstalledTables() public method

Get the installed table list from Doctrine.
public getInstalledTables ( ) : Doctrine\DBAL\Schema\Table[]
return Doctrine\DBAL\Schema\Table[]
    public function getInstalledTables()
    {
        if ($this->installedTables !== null) {
            return $this->installedTables;
        }
        /** @var $tables \Doctrine\DBAL\Schema\Table[] */
        $tables = $this->connection->getSchemaManager()->listTables();
        foreach ($tables as $table) {
            $alias = str_replace($this->app['schema.prefix'], '', $table->getName());
            $this->installedTables[$alias] = $table;
        }
        return $this->installedTables;
    }

Usage Example

Beispiel #1
0
 /**
  * Run the checks on the tables to see if they firstly exist, then if they
  * require update.
  */
 protected function checkTables()
 {
     $fromTables = $this->manager->getInstalledTables();
     $toTables = $this->manager->getSchemaTables();
     /** @var $fromTable Table */
     foreach ($toTables as $toTableAlias => $toTable) {
         $tableName = $toTable->getName();
         if (!isset($fromTables[$toTableAlias])) {
             // Table doesn't exist. Mark it for pending creation.
             $this->pending = true;
             $this->tablesCreate[$tableName] = $toTable;
             $this->getResponse()->addTitle($tableName, sprintf('Table `%s` is not present.', $tableName));
             $this->systemLog->debug('Database table missing: ' . $tableName);
             continue;
         }
         // Table exists. Check for required updates.
         $fromTable = $fromTables[$toTableAlias];
         $this->checkTable($fromTable, $toTable);
     }
 }