Guest User

Untitled

a guest
Sep 9th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. <?php
  2.  
  3. namespace MyBundle\Doctrine\DBAL;
  4.  
  5. use Doctrine\DBAL\Driver\PDOSqlite\Driver;
  6.  
  7. /**
  8. * Our own sqlite driver class, to add more methods to the sqlite sql syntax
  9. */
  10. class SqliteDriver extends Driver
  11. {
  12. /**
  13. * @param array $params
  14. * @param null $username
  15. * @param null $password
  16. * @param array $driverOptions
  17. * @return \Doctrine\DBAL\Driver\Connection|\Doctrine\DBAL\Driver\PDOConnection
  18. * @throws \Doctrine\DBAL\DBALException
  19. */
  20. public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
  21. {
  22. if (!isset($driverOptions['userDefinedFunctions'])) {
  23. $driverOptions['userDefinedFunctions'] = array();
  24. }
  25.  
  26. // Adding all needed sql function
  27. $driverOptions['userDefinedFunctions']['asin'] = array('callback' => 'asin', 'numArgs' => 1);
  28. $driverOptions['userDefinedFunctions']['sin'] = array('callback' => 'sin', 'numArgs' => 1);
  29. $driverOptions['userDefinedFunctions']['acos'] = array('callback' => 'acos', 'numArgs' => 1);
  30. $driverOptions['userDefinedFunctions']['cos'] = array('callback' => 'cos', 'numArgs' => 1);
  31. $driverOptions['userDefinedFunctions']['power'] = array('callback' => 'pow', 'numArgs' => 2);
  32. $driverOptions['userDefinedFunctions']['pi'] = array('callback' => 'pi', 'numArgs' => -1);
  33.  
  34. return parent::connect($params, $username, $password, $driverOptions);
  35. }
  36. }
Add Comment
Please, Sign In to add comment