<?php

class Database {
  private $_dbfile;
  private $_dbcnx;

  public function __construct($dbfile) {
    $this->_dbfile = $dbfile;
    $this->_dbcnx = false;
    while(!$this->_dbcnx) {
      $this->_dbcnx = new SQLite3($this->_dbfile);
      $this->_dbcnx->busyTimeout(5000);
    }
  }

  public function req($req) {
    return $this->_dbcnx->query($req);
  }

  public function next($dbreq) {
    return $dbreq->fetchArray();
  }

  public function reqFirst($req) {
    return $this->next( $this->req( $req ) );
  }
}

if(!isset($racine)) $racine='.';
$db = new Database($racine.'/karuba.sqlite');

?>