db.php 645 B

123456789101112131415161718192021222324252627
  1. <?php
  2. /**
  3. * Creates a database connection using the data in the config files.
  4. *
  5. * @return SQLite3Result Connection to the database.
  6. */
  7. function start_db(){
  8. global $path;
  9. //return new SQLiteDatabase($path["db"]);
  10. class SQLite extends SQLite3 {
  11. function __construct($file) {
  12. $this->open($file);
  13. }
  14. }
  15. $db = new SQLite3($path["db_key"]);
  16. if(!$db) {
  17. error_log($db->lastErrorMsg());
  18. }
  19. else {
  20. $db->query("attach '" . $path["db_data"] . "' as data");
  21. return $db;
  22. }
  23. }
  24. ?>