当前位置: 首页>>代码示例>>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;未经允许,请勿转载。