Ejemplo n.º 1
0
 /**
  * Initialize the database
  *
  * @throws Exception
  */
 protected function init()
 {
     /** @var helper_plugin_sqlite $sqlite */
     $this->sqlite = plugin_load('helper', 'sqlite');
     if (!$this->sqlite) {
         if (defined('DOKU_UNITTEST')) {
             throw new \Exception('Couldn\'t load sqlite.');
         }
         msg('The struct plugin requires the sqlite plugin. Please install it', -1);
         return;
     }
     if ($this->sqlite->getAdapter()->getName() != DOKU_EXT_PDO) {
         if (defined('DOKU_UNITTEST')) {
             throw new \Exception('Couldn\'t load PDO sqlite.');
         }
         msg('The struct plugin requires sqlite3 you\'re still using sqlite2', -1);
         $this->sqlite = null;
         return;
     }
     $this->sqlite->getAdapter()->setUseNativeAlter(true);
     // initialize the database connection
     if (!$this->sqlite->init('struct', DOKU_PLUGIN . 'struct/db/')) {
         if (defined('DOKU_UNITTEST')) {
             throw new \Exception('Couldn\'t init sqlite.');
         }
         return;
     }
     // register our JSON function with variable parameters
     // todo this might be useful to be moved into the sqlite plugin
     $this->sqlite->create_function('STRUCT_JSON', array($this, 'STRUCT_JSON'), -1);
 }