DB_Helper.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * DB helper file.
  4. *
  5. * Provides a helper to perform database operations.
  6. *
  7. * @category Helper.
  8. */
  9. /**
  10. * Require dependent files if not present.
  11. */
  12. require_once(PATH::HELPER . "Helper.php");
  13. /**
  14. * Database helper.
  15. *
  16. * Contains database utilities to connect.
  17. *
  18. * @category Helper.
  19. */
  20. final class DB extends Helper{
  21. /**
  22. * Creates a database connection using the data in the config files.
  23. *
  24. * @return resource Connection to the database.
  25. */
  26. public static function start(){
  27. /*class SQLite extends SQLite3 {
  28. function __construct($file) {
  29. $this->open($file);
  30. }
  31. }*/
  32. $db = new SQLite3(PATH::DB_KEY);
  33. if(!$db) {
  34. error_log($db->lastErrorMsg());
  35. }
  36. else {
  37. $db->query("attach '" . PATH::DB_DATA . "' as data");
  38. return $db;
  39. }
  40. }
  41. }
  42. ?>