当前位置: 首页>>代码示例>>PHP>>正文


PHP Connection::getSchemaManager方法代码示例

本文整理汇总了PHP中Doctrine\DBAL\Connection::getSchemaManager方法的典型用法代码示例。如果您正苦于以下问题:PHP Connection::getSchemaManager方法的具体用法?PHP Connection::getSchemaManager怎么用?PHP Connection::getSchemaManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\DBAL\Connection的用法示例。


在下文中一共展示了Connection::getSchemaManager方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getMetaData

 /**
  * Returns a database metadata object that can be used to retrieve table
  * meta data from the database.
  *
  * @return PHPUnit_Extensions_Database_DB_IMetaData
  */
 public function getMetaData()
 {
     if (null === $this->_metadata) {
         $this->_metadata = new DoctrineMetadata($this->_conn->getSchemaManager(), $this->_conn->getDatabase());
     }
     return $this->_metadata;
 }
开发者ID:matiasraies,项目名称:Symfony2Inta,代码行数:13,代码来源:TestConnection.php

示例2: migrateBadgeTables

 /**
  * @param Connection $connection
  * @param AppKernel  $kernel
  *
  * @throws \Claroline\MigrationBundle\Migrator\InvalidDirectionException
  * @throws \Claroline\MigrationBundle\Migrator\InvalidVersionException
  * @throws \Doctrine\DBAL\Migrations\MigrationException
  */
 protected function migrateBadgeTables(Connection $connection, AppKernel $kernel)
 {
     $portfolioBundle = $this->container->get('claroline.persistence.object_manager')->getRepository('ClarolineCoreBundle:Plugin')->findBy(array('vendorName' => 'Icap', 'bundleName' => 'PortfolioBundle'));
     $portfolioBundle = count($portfolioBundle) === 1 ? true : false;
     if (!$portfolioBundle && $connection->getSchemaManager()->tablesExist(['icap__portfolio_widget_badges'])) {
         $this->log('Deleting portfolios badges tables...');
         $connection->getSchemaManager()->dropTable('icap__portfolio_widget_badges_badge');
         $connection->getSchemaManager()->dropTable('icap__portfolio_widget_badges');
         $this->log('Portfolios badges tables deleted.');
     }
     if ($portfolioBundle && !$connection->getSchemaManager()->tablesExist(['icap__portfolio_widget_badges'])) {
         $badgeBundle = $kernel->getBundle('IcapBadgeBundle');
         $this->log('Executing migrations for portfolio interaction');
         $migrationsDir = "{$badgeBundle->getPath()}/Installation/Migrations";
         $migrationsName = "{$badgeBundle->getName()} migration";
         $migrationsNamespace = "{$badgeBundle->getNamespace()}\\Installation\\Migrations";
         $migrationsTableName = 'doctrine_' . strtolower($badgeBundle->getName()) . '_versions';
         $config = new Configuration($connection);
         $config->setName($migrationsName);
         $config->setMigrationsDirectory($migrationsDir);
         $config->setMigrationsNamespace($migrationsNamespace);
         $config->setMigrationsTableName($migrationsTableName);
         $config->registerMigrationsFromDirectory($migrationsDir);
         $migration = new Migration($config);
         $executedQueriesNumber = $migration->migrate('20150929141509');
         $this->log(sprintf('%d queries executed', $executedQueriesNumber));
     }
 }
开发者ID:claroline,项目名称:distribution,代码行数:36,代码来源:Updater060300.php

示例3: preUpdate

 /**
  * @param Connection $connection
  * @param AppKernel  $kernel
  */
 public function preUpdate(Connection $connection, AppKernel $kernel)
 {
     /** @var \Symfony\Component\HttpKernel\Bundle\Bundle[] $bundles */
     $bundles = $kernel->getBundles();
     $isPortfolioBundleInstalled = false;
     foreach ($bundles as $bundle) {
         if ('IcapPortfolioBundle' === $bundle->getName()) {
             $isPortfolioBundleInstalled = true;
         }
     }
     if ($connection->getSchemaManager()->tablesExist(['icap__portfolio_widget_badges'])) {
         if ($isPortfolioBundleInstalled) {
             $this->log('Found existing database schema: skipping install migration...');
             $config = new Configuration($connection);
             $config->setMigrationsTableName('doctrine_icapbadgebundle_versions');
             $config->setMigrationsNamespace('claro_badge');
             // required but useless
             $config->setMigrationsDirectory('claro_badge');
             // idem
             try {
                 $version = new Version($config, '20150929141509', 'stdClass');
                 $version->markMigrated();
             } catch (\Exception $e) {
                 $this->log('Already migrated');
             }
         } else {
             $this->log('Deleting badges tables for portfolio...');
             $connection->getSchemaManager()->dropTable('icap__portfolio_widget_badges_badge');
             $connection->getSchemaManager()->dropTable('icap__portfolio_widget_badges');
             $this->log('badges tables for portfolio deleted.');
         }
     }
 }
开发者ID:claroline,项目名称:distribution,代码行数:37,代码来源:Updater060200.php

示例4: processQueueCallback

 /**
  * ->processQueueCallback(function (\Dja\Db\Model\Metadata $metadata, \Doctrine\DBAL\Schema\Table $table, array $sql, \Doctrine\DBAL\Connection $db) {})
  * @param callable|\Closure $callBack
  */
 public function processQueueCallback(\Closure $callBack)
 {
     $callbackQueue = [];
     while (count($this->generateQueue)) {
         $modelName = array_shift($this->generateQueue);
         try {
             /** @var Metadata $metadata */
             $metadata = $modelName::metadata();
             $tblName = $metadata->getDbTableName();
             if ($this->db->getSchemaManager()->tablesExist($tblName)) {
                 continue;
             }
             if (isset($this->generated[$tblName])) {
                 continue;
             }
             $table = $this->metadataToTable($metadata);
             $this->generated[$tblName] = 1;
             $sql = $this->dp->getCreateTableSQL($table, AbstractPlatform::CREATE_INDEXES);
             array_unshift($callbackQueue, [$metadata, $table, $sql]);
             $fks = $table->getForeignKeys();
             if (count($fks)) {
                 $sql = [];
                 foreach ($fks as $fk) {
                     $sql[] = $this->dp->getCreateForeignKeySQL($fk, $table);
                 }
                 array_push($callbackQueue, [$metadata, $table, $sql]);
             }
         } catch (\Exception $e) {
             pr($e->__toString());
         }
     }
     foreach ($callbackQueue as $args) {
         $callBack($args[0], $args[1], $args[2], $this->db);
     }
 }
开发者ID:buldezir,项目名称:dja_orm,代码行数:39,代码来源:Creation.php

示例5: restorePortfolioTitle

 public function restorePortfolioTitle()
 {
     $totalPortfolioProcessed = 0;
     $nbPortfolioProcessed = 0;
     if ($this->connection->getSchemaManager()->tablesExist(array('icap__portfolio_widget_title'))) {
         $this->log('Restoring portfolio titles...');
         $rowPortfolioTitles = $this->connection->query('SELECT * FROM icap__portfolio_widget_title');
         $sql = 'SELECT aw.id, aw.user_id FROM icap__portfolio_abstract_widget aw WHERE id = :id';
         $stmt = $this->connection->prepare($sql);
         foreach ($rowPortfolioTitles as $rowPortfolioTitle) {
             $stmt->bindValue('id', $rowPortfolioTitle['id']);
             $stmt->execute();
             foreach ($stmt->fetchAll() as $rowAbstractWidget) {
                 $this->connection->update('icap__portfolio', ['title' => $rowPortfolioTitle['title'], 'slug' => $rowPortfolioTitle['slug']], ['id' => $rowAbstractWidget['user_id']]);
             }
             $this->connection->delete('icap__portfolio_abstract_widget', ['id' => $rowPortfolioTitle['id']]);
             ++$nbPortfolioProcessed;
             if ($nbPortfolioProcessed >= 10) {
                 $totalPortfolioProcessed += $nbPortfolioProcessed;
                 $nbPortfolioProcessed = 0;
                 $this->log('    processing portfolio...');
             }
         }
         $this->log(sprintf('  %d portfolio processed', $totalPortfolioProcessed + $nbPortfolioProcessed));
         $this->connection->delete('icap__portfolio_widget_type', ['name' => 'title']);
         $this->connection->getSchemaManager()->dropTable('icap__portfolio_widget_title');
     }
 }
开发者ID:claroline,项目名称:distribution,代码行数:28,代码来源:Updater050002.php

示例6: __construct

 /**
  * Default constructor
  *
  * @param  $config array Database connection setting
  */
 public function __construct($config)
 {
     $this->config = $config;
     $this->conn = \Doctrine\DBAL\DriverManager::getConnection($this->config);
     $this->conn->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'enum');
     $this->conn->getDatabasePlatform()->registerDoctrineTypeMapping('point', 'point');
     $this->sm = $this->conn->getSchemaManager();
 }
开发者ID:mp-php,项目名称:fuel-packages-dbdocs,代码行数:13,代码来源:dbdocs.php

示例7: __construct

 public function __construct(Connection $conn, StorageKeyGeneratorInterface $storageKeyGenerator)
 {
     $this->conn = $conn;
     $this->storageKeyGenerator = $storageKeyGenerator;
     $this->schemaManager = $this->conn->getSchemaManager();
     $this->keyColumn = $this->conn->quoteIdentifier(self::KEY_COLUMN);
     $this->valueColumn = $this->conn->quoteIdentifier(self::VALUE_COLUMN);
 }
开发者ID:alinnflorinn,项目名称:CraueFormFlowBundle,代码行数:8,代码来源:DoctrineStorage.php

示例8: postUpdate

 public function postUpdate()
 {
     $em = $this->container->get('doctrine.orm.entity_manager');
     $process = false;
     if (in_array('claro_forum_subject_temp', $this->conn->getSchemaManager()->listTableNames())) {
         $columns = $this->conn->getSchemaManager()->listTableColumns('claro_forum_subject_temp');
         foreach ($columns as $column) {
             if ($column->getName() === 'forum_id') {
                 $process = true;
                 break;
             }
         }
     }
     if ($process) {
         $this->log('restoring the subjects...');
         $forums = $em->getRepository('ClarolineForumBundle:Forum')->findAll();
         $sql = 'SELECT * FROM claro_forum_subject_temp WHERE forum_id = :forumId';
         $stmt = $this->conn->prepare($sql);
         foreach ($forums as $forum) {
             $category = new Category();
             $category->setName($forum->getResourceNode()->getName());
             $category->setForum($forum);
             $em->persist($category);
             $em->flush();
             $stmt->bindValue('forumId', $forum->getId());
             $stmt->execute();
             foreach ($stmt->fetchAll() as $rowsSubject) {
                 $this->conn->query("INSERT INTO claro_forum_subject VALUES (\n                        {$rowsSubject['id']},\n                        {$category->getId()},\n                        {$rowsSubject['user_id']},\n                        {$this->conn->quote($rowsSubject['title'])},\n                        '{$rowsSubject['created']}',\n                        '{$rowsSubject['updated']}',\n                        false\n                    )");
             }
         }
         $this->log('restoring the messages...');
         $this->conn->query('INSERT IGNORE INTO claro_forum_message SELECT * FROM claro_forum_message_temp');
         $this->conn->query('DROP TABLE claro_forum_message_temp');
         $this->conn->query('DROP TABLE claro_forum_subject_temp');
         $this->conn->query('DROP TABLE claro_forum_options');
     } else {
         $this->log('categories already added');
     }
     $widget = $em->getRepository('ClarolineCoreBundle:Widget\\Widget')->findBy(array('name' => 'claroline_forum_widget'));
     if (!$widget) {
         $this->log('adding the forum widget...');
         $plugin = $em->getRepository('ClarolineCoreBundle:Plugin')->findOneBy(array('vendorName' => 'Claroline', 'bundleName' => 'ForumBundle'));
         $widget = new Widget();
         $widget->setName('claroline_forum_widget');
         $widget->setDisplayableInDesktop(true);
         $widget->setDisplayableInWorkspace(true);
         $widget->setConfigurable(false);
         $widget->setExportable(false);
         $widget->setIcon('none');
         $widget->setPlugin($plugin);
         $em->persist($widget);
         $plugin->setHasOptions(true);
         $em->persist($widget);
         $em->flush();
     } else {
         $this->log('forum widget already added');
     }
 }
开发者ID:claroline,项目名称:distribution,代码行数:58,代码来源:Updater020200.php

示例9: __construct

 public function __construct(Version $version)
 {
     $config = $version->getConfiguration();
     $this->version = $version;
     $this->connection = $config->getConnection();
     $this->sm = $this->connection->getSchemaManager();
     $this->platform = $this->connection->getDatabasePlatform();
     $this->outputWriter = $config->getOutputWriter();
 }
开发者ID:saberyounis,项目名称:Sonata-Project,代码行数:9,代码来源:AbstractMigration.php

示例10: shouldBeRun

 /**
  * {@inheritdoc}
  */
 public function shouldBeRun()
 {
     $schemaManager = $this->connection->getSchemaManager();
     if (!$schemaManager->tablesExist('tl_layout')) {
         return false;
     }
     $columns = $schemaManager->listTableColumns('tl_layout');
     return !isset($columns['viewport']);
 }
开发者ID:aschempp,项目名称:contao-installation-bundle,代码行数:12,代码来源:Version330Update.php

示例11: testSkipMigrateUp

 public function testSkipMigrateUp()
 {
     $version = new \Doctrine\DBAL\Migrations\Version($this->config, 1, 'Doctrine\\DBAL\\Migrations\\Tests\\Functional\\MigrationSkipMigration');
     $this->assertFalse($this->config->hasVersionMigrated($version));
     $version->execute('up');
     $schema = $this->connection->getSchemaManager()->createSchema();
     $this->assertFalse($schema->hasTable('foo'));
     $this->assertTrue($this->config->hasVersionMigrated($version));
 }
开发者ID:comporu,项目名称:migrations,代码行数:9,代码来源:FunctionalTest.php

示例12: isTableExist

 /**
  * Check if the given table exists in a database
  *
  * @param string $tableName
  * @return bool TRUE if a table exists; otherwise, FALSE
  */
 public function isTableExist($tableName)
 {
     $result = false;
     try {
         $this->ensureConnected();
         $result = $this->connection->isConnected() && (bool) array_intersect([$tableName], $this->connection->getSchemaManager()->listTableNames());
     } catch (\PDOException $e) {
     }
     return $result;
 }
开发者ID:Maksold,项目名称:platform,代码行数:16,代码来源:MigrationEvent.php

示例13: shouldBeRun

 /**
  * {@inheritdoc}
  */
 public function shouldBeRun()
 {
     $schemaManager = $this->connection->getSchemaManager();
     if (!$schemaManager->tablesExist('tl_member')) {
         return false;
     }
     $sql = $this->connection->getDatabasePlatform()->getListTableIndexesSQL('tl_member', $this->connection->getDatabase());
     $index = $this->connection->fetchAssoc($sql . " AND INDEX_NAME = 'username'");
     return '0' !== $index['Non_Unique'];
 }
开发者ID:aschempp,项目名称:contao-installation-bundle,代码行数:13,代码来源:Version350Update.php

示例14: setUp

 public function setUp()
 {
     if (!extension_loaded('pdo_sqlite')) {
         $this->markTestSkipped('The Redis extension is not available.');
     }
     $schema = new TableEventStoreSchema();
     $tableSchema = $schema->getTableSchema();
     $this->conn = DriverManager::getConnection(['driver' => 'pdo_sqlite', 'memory' => true]);
     $this->conn->getSchemaManager()->createTable($tableSchema);
     $this->tableEventStore = new TableEventStore(new SomeSerializer(), $this->conn, $tableSchema->getName());
 }
开发者ID:pauci,项目名称:cqrs,代码行数:11,代码来源:TableEventStoreTest.php

示例15: createQueryTestTable

 protected function createQueryTestTable()
 {
     $table = new \Doctrine\DBAL\Schema\Table('query_test');
     $table->addColumn('id', 'integer');
     $table->addColumn('val1', 'string');
     $table->addColumn('val2', 'integer');
     try {
         $this->connection->getSchemaManager()->createTable($table);
     } catch (DBALException $e) {
     }
 }
开发者ID:Pixy,项目名称:ezpublish-kernel,代码行数:11,代码来源:TestCase.php


注:本文中的Doctrine\DBAL\Connection::getSchemaManager方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。