當前位置: 首頁>>代碼示例>>PHP>>正文


PHP RegistryInterface::getConnection方法代碼示例

本文整理匯總了PHP中Symfony\Bridge\Doctrine\RegistryInterface::getConnection方法的典型用法代碼示例。如果您正苦於以下問題:PHP RegistryInterface::getConnection方法的具體用法?PHP RegistryInterface::getConnection怎麽用?PHP RegistryInterface::getConnection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Bridge\Doctrine\RegistryInterface的用法示例。


在下文中一共展示了RegistryInterface::getConnection方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __construct

 /**
  * Constructor
  *
  * @param RegistryInterface      $registry
  * @param string                 $class
  * @param RouterInterface        $router
  * @param string                 $routeName
  */
 public function __construct(RegistryInterface $registry, $class, RouterInterface $router, $routeName)
 {
     $tableName = $registry->getManager()->getClassMetadata($class)->table['name'];
     $dql = "SELECT p.id as productId, p.slug as slug,  p.updated_at as lastmod, 'weekly' as changefreq, '0.5' as priority " . "FROM " . $tableName . " p " . "WHERE p.enabled = 1";
     $source = new DoctrineDBALConnectionSourceIterator($registry->getConnection(), $dql);
     $this->iterator = new SymfonySitemapSourceIterator($source, $router, $routeName, array('productId' => null, 'slug' => null));
 }
開發者ID:Dicoding,項目名稱:ecommerce,代碼行數:15,代碼來源:SeoProductIterator.php

示例2: generateReference

 /**
  * generate a correct reference number.
  *
  * @param mixed  $object
  * @param string $tableName
  *
  * @throws \Exception
  *
  * @return Exception|string
  */
 protected function generateReference($object, $tableName)
 {
     $date = new \DateTime();
     $sql = sprintf("SELECT count(id) as counter FROM %s WHERE created_at >= '%s' AND reference IS NOT NULL", $tableName, $date->format('Y-m-d'));
     $this->registry->getConnection()->exec(sprintf('LOCK TABLES %s WRITE', $tableName));
     try {
         $statement = $this->registry->getConnection()->query($sql);
         $row = $statement->fetch();
         $reference = sprintf('%02d%02d%02d%06d', $date->format('y'), $date->format('n'), $date->format('j'), $row['counter'] + 1);
         $this->registry->getConnection()->update($tableName, array('reference' => $reference), array('id' => $object->getId()));
         $object->setReference($reference);
     } catch (\Exception $e) {
         $this->registry->getConnection()->exec(sprintf('UNLOCK TABLES'));
         throw $e;
     }
     $this->registry->getConnection()->exec(sprintf('UNLOCK TABLES'));
     return $reference;
 }
開發者ID:sonata-project,項目名稱:ecommerce,代碼行數:28,代碼來源:MysqlReference.php

示例3: isReservedKeyword

 /**
  * Check that the keyword is a reserved word for the database system.
  *
  * @param string $keyword
  *
  * @return boolean
  */
 public function isReservedKeyword($keyword)
 {
     return $this->registry->getConnection()->getDatabasePlatform()->getReservedKeywordsList()->isKeyword($keyword);
 }
開發者ID:axelvnk,項目名稱:KunstmaanBundlesCMS,代碼行數:11,代碼來源:KunstmaanGenerator.php

示例4: releaseLock

 public function releaseLock($lock)
 {
     $connection = $this->registry->getConnection();
     $connection->executeQuery("SELECT RELEASE_LOCK(':lock')", array('lock' => $lock));
     $this->logger->addInfo(sprintf('released named lock "%s"', $lock));
 }
開發者ID:symfony-tutorial,項目名稱:app,代碼行數:6,代碼來源:UtilService.php


注:本文中的Symfony\Bridge\Doctrine\RegistryInterface::getConnection方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。