1<?php
2/**
3 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
4 * @author     Steven te Brinke <s.tebrinke@utwente.nl>
5 */
6// must be run within Dokuwiki
7if(!defined('DOKU_INC')) die('Meh.');
8
9require_once(DOKU_PLUGIN.'strata/driver/driver.php');
10
11/**
12 * The MySQL database driver.
13 */
14class plugin_strata_driver_mysql extends plugin_strata_driver {
15
16    public function castToNumber($val) {
17        return "CAST($val AS DECIMAL)";
18    }
19
20    public function ci($val='?') {
21        return "$val COLLATE utf8mb4_unicode_ci";
22    }
23
24    protected function initializeConnection() {
25        $this->query('SET NAMES utf8mb4');
26        $this->query("SET sql_mode = 'PIPES_AS_CONCAT'"); // Ensure that || works as string concatenation
27    }
28
29    public function isInitialized() {
30        return $this->_db->query("SHOW TABLES LIKE 'data'")->rowCount() != 0;
31    }
32}
33