Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace MyBundle\Doctrine\DBAL;
- use Doctrine\DBAL\Driver\PDOSqlite\Driver;
- /**
- * Our own sqlite driver class, to add more methods to the sqlite sql syntax
- */
- class SqliteDriver extends Driver
- {
- /**
- * @param array $params
- * @param null $username
- * @param null $password
- * @param array $driverOptions
- * @return \Doctrine\DBAL\Driver\Connection|\Doctrine\DBAL\Driver\PDOConnection
- * @throws \Doctrine\DBAL\DBALException
- */
- public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
- {
- if (!isset($driverOptions['userDefinedFunctions'])) {
- $driverOptions['userDefinedFunctions'] = array();
- }
- // Adding all needed sql function
- $driverOptions['userDefinedFunctions']['asin'] = array('callback' => 'asin', 'numArgs' => 1);
- $driverOptions['userDefinedFunctions']['sin'] = array('callback' => 'sin', 'numArgs' => 1);
- $driverOptions['userDefinedFunctions']['acos'] = array('callback' => 'acos', 'numArgs' => 1);
- $driverOptions['userDefinedFunctions']['cos'] = array('callback' => 'cos', 'numArgs' => 1);
- $driverOptions['userDefinedFunctions']['power'] = array('callback' => 'pow', 'numArgs' => 2);
- $driverOptions['userDefinedFunctions']['pi'] = array('callback' => 'pi', 'numArgs' => -1);
- return parent::connect($params, $username, $password, $driverOptions);
- }
- }
Add Comment
Please, Sign In to add comment