DB.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * DB helper file.
  4. *
  5. * Provides a helper to perform database operations.
  6. *
  7. * @author Iñigo Valentin <i@inigovalentin.com>
  8. * @license https://www.gnu.org/licenses/gpl-3.0.en.html GNU General Public License V3
  9. * @package SWDB
  10. */
  11. require_once(PATH::HELPER . "HELPER.php");
  12. /**
  13. * Database helper.
  14. *
  15. * Contains database utilities to connect.
  16. *
  17. * @category Helper.
  18. */
  19. final class DB extends Helper{
  20. /**
  21. * Creates a database connection using the data in the config files.
  22. *
  23. * @return resource Connection to the database.
  24. */
  25. public static function start(){
  26. /*class SQLite extends SQLite3 {
  27. function __construct($file) {
  28. $this->open($file);
  29. }
  30. }*/
  31. $db = new SQLite3(":memory:");
  32. if(!$db) {
  33. error_log($db->lastErrorMsg());
  34. }
  35. else {
  36. $db->query("attach '" . PATH::DB_DATA . "' as data");
  37. $db->query("attach '" . PATH::DB_KEY . "' as key");
  38. return $db;
  39. }
  40. }
  41. }