1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- namespace OC\DB;
- use Doctrine\Common\EventSubscriber;
- use Doctrine\DBAL\Event\ConnectionEventArgs;
- use Doctrine\DBAL\Events;
- class SQLiteSessionInit implements EventSubscriber {
-
- private $caseSensitiveLike;
-
- private $journalMode;
-
- public function __construct($caseSensitiveLike, $journalMode) {
- $this->caseSensitiveLike = $caseSensitiveLike;
- $this->journalMode = $journalMode;
- }
-
- public function postConnect(ConnectionEventArgs $args) {
- $sensitive = $this->caseSensitiveLike ? 'true' : 'false';
- $args->getConnection()->executeUpdate('PRAGMA case_sensitive_like = ' . $sensitive);
- $args->getConnection()->executeUpdate('PRAGMA journal_mode = ' . $this->journalMode);
-
- $connection = $args->getConnection()->getWrappedConnection();
- $pdo = $connection->getWrappedConnection();
- $pdo->sqliteCreateFunction('md5', 'md5', 1);
- }
- public function getSubscribedEvents() {
- return [Events::postConnect];
- }
- }
|