eZ\Publish\Core\Persistence\Doctrine\ConnectionHandler::createFromConnection PHP Метод

createFromConnection() публичный статический Метод

Create a Connection Handler from given Doctrine $connection.
public static createFromConnection ( Doctrine\DBAL\Connection $connection ) : ConnectionHandler
$connection Doctrine\DBAL\Connection
Результат ConnectionHandler
    public static function createFromConnection(Connection $connection)
    {
        $driver = $connection->getDriver()->getName();
        if ($driver === 'pdo_sqlite') {
            return new ConnectionHandler\SqliteConnectionHandler($connection);
        }
        if ($driver === 'pdo_pgsql') {
            return new ConnectionHandler\PostgresConnectionHandler($connection);
        }
        return new self($connection);
    }

Usage Example

Пример #1
0
 /**
  * Get a eZ Doctrine database connection handler.
  *
  * Get a ConnectionHandler, which can be used to interact with the configured
  * database. The database connection string is read from an optional
  * environment variable "DATABASE" and defaults to an in-memory SQLite
  * database.
  *
  * @return \eZ\Publish\Core\Persistence\Doctrine\ConnectionHandler
  */
 public function getDatabaseHandler()
 {
     if (!$this->handler) {
         $this->handler = ConnectionHandler::createFromConnection($this->getDatabaseConnection());
         $this->db = $this->handler->getName();
     }
     return $this->handler;
 }