Advertisement
Guest User

spatialite sqilte dbal

a guest
Dec 9th, 2016
112
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. namespace AppBundle\Doctrine\DBAL\Driver\Sqlite;
  4.  
  5. use Exception;
  6. use Jsor\DBAL\Driver\Sqlite3\Connection;
  7. use Jsor\DBAL\Driver\Sqlite3\Driver as BaseDriver;
  8.  
  9. class Driver extends BaseDriver
  10. {
  11.     /**
  12.      * @var array
  13.      */
  14.     protected $_userDefinedExtensions = [
  15.         'mod_spatialite.so',
  16.     ];
  17.  
  18.     /**
  19.      * Tries to establish a database connection to SQLite.
  20.      *
  21.      * @param  array      $params
  22.      * @param  string     $username
  23.      * @param  string     $password
  24.      * @param  array      $driverOptions
  25.      * @return Connection
  26.      */
  27.     public function connect(array $params, $username = null, $password = null, array $driverOptions = [])
  28.     {
  29.         if (isset($driverOptions['userDefinedFunctions'])) {
  30.             $this->_userDefinedFunctions = array_merge(
  31.                 $this->_userDefinedFunctions, $driverOptions['userDefinedFunctions']);
  32.         }
  33.  
  34.         if (isset($driverOptions['userDefinedExtensions'])) {
  35.             $this->_userDefinedExtensions = array_merge(
  36.                 $this->_userDefinedExtensions,
  37.                 $driverOptions['userDefinedExtensions']
  38.             );
  39.         }
  40.  
  41.         if (isset($params['path'])) {
  42.             $filename = $params['path'];
  43.         } elseif (isset($params['dbname'])) {
  44.             $filename = $params['dbname'];
  45.         } elseif (isset($params['memory'])) {
  46.             $filename = ':memory:';
  47.         } else {
  48.             throw new Exception('Either a dbname, path or a memory entry is required in $params');
  49.         }
  50.  
  51.         $connection = new Connection(
  52.             $filename,
  53.             isset($params['flags']) ? $params['flags'] : null,
  54.             isset($params['encryptionKey']) ? $params['encryptionKey'] : null,
  55.             isset($params['busyTimeout']) ? $params['busyTimeout'] : null,
  56.             $this->_userDefinedFunctions,
  57.             $this->_userDefinedExtensions
  58.         );
  59.  
  60.         return $connection;
  61.     }
  62. }
Advertisement
RAW Paste Data Copied
Advertisement