Symfony\Bridge\Doctrine\RegistryInterface::getConnection PHP Method

getConnection() public method

Gets the named connection.
public getConnection ( string $name = null ) : Doctrine\DBAL\Connection
$name string The connection name (null for the default one)
return Doctrine\DBAL\Connection
    function getConnection($name = null);

Usage Example

 /**
  * 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));
 }
All Usage Examples Of Symfony\Bridge\Doctrine\RegistryInterface::getConnection