/** * Checks whether the translations table exists in the database * * @return bool */ protected function checkDatabase() { if (null === $this->dbCheck) { $this->dbCheck = SafeDatabaseChecker::tablesExist($this->getEntityManager()->getConnection(), SafeDatabaseChecker::getTableName($this->doctrine, Translation::ENTITY_NAME)); } return $this->dbCheck; }
/** * @return bool */ public function checkDatabase() { if (null !== $this->dbCheck) { return $this->dbCheck; } if ($this->lockObject->isLocked()) { return true; } $this->dbCheck = SafeDatabaseChecker::tablesExist($this->getEntityManager()->getConnection(), $this->requiredTables); return $this->dbCheck; }
/** * {@inheritDoc} */ public function process(ContainerBuilder $container) { if (!$container->hasDefinition(self::SERVICE_KEY)) { return; } if (!$container->hasParameter('installed') || !$container->getParameter('installed')) { return; } // register event listeners // by performance reasons native SQL is used here rather than ORM // ORM usage leads unnecessary loading of Doctrine metadata and ORO entity configs which is not needed here /** @var Connection $connection */ $connection = $container->get('doctrine.dbal.default_connection'); if (SafeDatabaseChecker::tablesExist($connection, self::EVENT_TABLE_NAME)) { $dispatcher = $container->findDefinition(self::DISPATCHER_KEY); $rows = $connection->fetchAll('SELECT name FROM ' . self::EVENT_TABLE_NAME); foreach ($rows as $row) { $dispatcher->addMethodCall('addListenerService', [$row['name'], [self::SERVICE_KEY, 'process']]); } } }
/** * Check if user table exists in db * * @return bool */ protected function checkDatabase() { $className = $this->getOwnershipMetadataProvider()->getBasicLevelClass(); return SafeDatabaseChecker::tablesExist($this->getManagerForClass($className)->getConnection(), SafeDatabaseChecker::getTableName($this->getContainer()->get('doctrine'), $className)); }
/** * @expectedException \Exception * @expectedExceptionMessage unexpected */ public function testTablesExistShouldRethrowUnexpectedException() { $connection = $this->getMockBuilder('Doctrine\\DBAL\\Connection')->disableOriginalConstructor()->getMock(); $connection->expects($this->once())->method('connect')->willThrowException(new \Exception('unexpected')); SafeDatabaseChecker::tablesExist($connection, 'table'); }
/** * Checks whether the translations table exists in the database * * @return bool */ protected function checkDatabase() { if (null === $this->dbCheck) { $doctrine = $this->container->get('doctrine'); $this->dbCheck = SafeDatabaseChecker::tablesExist($doctrine->getManagerForClass(Translation::ENTITY_NAME)->getConnection(), SafeDatabaseChecker::getTableName($doctrine, Translation::ENTITY_NAME)); } return $this->dbCheck; }
/** * 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) { return SafeDatabaseChecker::tablesExist($this->connection, $tableName); }