Our framework must have a data abstraction layer to facilitate database operations painlessly. We are going to provide support to three popular databases: SQLite, PostgreSQL, and MySQL. Here is the code of our data abstraction layer in core/main/db.php
:
<? include_once("dbdrivers/abstract.dbdriver.php"); class db { private $dbengine; private $state = "development"; public function __construct() { $config = loader::load("config"); $dbengineinfo = $config->db; if (!$dbengineinfo['usedb']==false) { $driver = $dbengineinfo[$this->state]['dbtype'].'driver'; include_once("dbdrivers/{$driver}.php"); $dbengine = new $driver($dbengineinfo[$this->state]); $this->dbengine = $dbengine; } } public function setDbState($state) { //must be 'development'/'production'/'test' or whatever if (empty($this->dbengine)) return 0; $config = loader::load("config"); $dbengineinfo = $config->db;...