xref: /plugin/struct/helper/db.php (revision a57a64a5064de0f3bcdccaae3fe663e44d732149)
1<?php
2/**
3 * DokuWiki Plugin struct (Helper Component)
4 *
5 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
6 * @author  Andreas Gohr, Michael Große <dokuwiki@cosmocode.de>
7 */
8
9// must be run within Dokuwiki
10if(!defined('DOKU_INC')) die();
11
12class helper_plugin_struct_db extends DokuWiki_Plugin {
13    /** @var helper_plugin_sqlite */
14    protected $sqlite;
15
16    public function __construct() {
17        /** @var helper_plugin_sqlite $sqlite */
18        $this->sqlite = plugin_load('helper', 'sqlite');
19        if(!$this->sqlite) {
20            msg('The struct plugin requires the sqlite plugin. Please install it', -1);
21            return;
22        }
23
24        if($this->sqlite->getAdapter()->getName() != DOKU_EXT_PDO) {
25            msg('The struct plugin requires sqlite3 you\'re still using sqlite2');
26            $this->sqlite = null;
27            return;
28        }
29        $this->sqlite->getAdapter()->setUseNativeAlter(true);
30
31        // initialize the database connection
32        if(!$this->sqlite->init('struct', DOKU_PLUGIN . 'struct/db/')) {
33            return;
34        }
35    }
36
37    /**
38     * @return helper_plugin_sqlite|null
39     */
40    public function getDB() {
41        return $this->sqlite;
42    }
43
44}
45
46// vim:ts=4:sw=4:et:
47