ludofleury
8/9/2013 - 9:11 AM

single-connection-driver.php

<?php

namespace Playbloom\Tests;

use Doctrine\DBAL\Driver\PDOMySql\Driver;

class MysqlDriver extends Driver
{
    private static $connection;

    /**
     * Attempts to establish a connection with the underlying driver.
     *
     * @param  array                            $params
     * @param  string                           $username
     * @param  string                           $password
     * @param  array                            $driverOptions
     * @return \Doctrine\DBAL\Driver\Connection
     */
    public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
    {
        if (null === self::$connection) {
            self::$connection = parent::connect($params, $username, $password, $driverOptions);
        }

        return self::$connection;
    }
}