Last active
March 16, 2019 17:24
-
-
Save jkuchar/13c640fb2ac071da14f4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace jkuchar\Doctrine\DBAL\Driver\PDOPgSql; | |
use Doctrine\DBAL\Driver\PDOPgSql\Driver as DoctrineOriginalDriver; | |
/** | |
* Adds ability to set search path to PostgreSQL driver | |
* @package App\Doctrine | |
*/ | |
class Driver extends DoctrineOriginalDriver | |
{ | |
public function connect(array $params, $username = null, $password = null, array $driverOptions = array()) | |
{ | |
$connection = parent::connect($params, $username, $password, $driverOptions); | |
$searchPath = isset($params["options"]["search_path"]) ? $params["options"]["search_path"] : NULL; | |
if($searchPath) { | |
// todo: properly escape search path | |
$connection->exec("SET SEARCH_PATH TO {$searchPath};"); | |
} | |
return $connection; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment