Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace AppBundle\Doctrine\DBAL\Driver\Sqlite;
- use Exception;
- use Jsor\DBAL\Driver\Sqlite3\Connection;
- use Jsor\DBAL\Driver\Sqlite3\Driver as BaseDriver;
- class Driver extends BaseDriver
- {
- /**
- * @var array
- */
- protected $_userDefinedExtensions = [
- 'mod_spatialite.so',
- ];
- /**
- * Tries to establish a database connection to SQLite.
- *
- * @param array $params
- * @param string $username
- * @param string $password
- * @param array $driverOptions
- * @return Connection
- */
- public function connect(array $params, $username = null, $password = null, array $driverOptions = [])
- {
- if (isset($driverOptions['userDefinedFunctions'])) {
- $this->_userDefinedFunctions = array_merge(
- $this->_userDefinedFunctions, $driverOptions['userDefinedFunctions']);
- }
- if (isset($driverOptions['userDefinedExtensions'])) {
- $this->_userDefinedExtensions = array_merge(
- $this->_userDefinedExtensions,
- $driverOptions['userDefinedExtensions']
- );
- }
- if (isset($params['path'])) {
- $filename = $params['path'];
- } elseif (isset($params['dbname'])) {
- $filename = $params['dbname'];
- } elseif (isset($params['memory'])) {
- $filename = ':memory:';
- } else {
- throw new Exception('Either a dbname, path or a memory entry is required in $params');
- }
- $connection = new Connection(
- $filename,
- isset($params['flags']) ? $params['flags'] : null,
- isset($params['encryptionKey']) ? $params['encryptionKey'] : null,
- isset($params['busyTimeout']) ? $params['busyTimeout'] : null,
- $this->_userDefinedFunctions,
- $this->_userDefinedExtensions
- );
- return $connection;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement