本文整理汇总了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));
}
示例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;
}
示例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);
}
示例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));
}