2 // Import framework stuff
3 use CoreFramework\Configuration\FrameworkConfiguration;
4 use CoreFramework\Connection\Database\DatabaseConnection;
5 use CoreFramework\Object\BaseFrameworkSystem;
6 use CoreFramework\Middleware\Debug\DebugMiddleware;
9 * Initializes the database layer
11 * @author Roland Haeder <webmaster@shipsimu.org>
13 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
14 * @license GNU GPL 3.0 or any newer version
15 * @link http://www.shipsimu.org
17 * @todo Minimize these includes
19 * This program is free software: you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation, either version 3 of the License, or
22 * (at your option) any later version.
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
29 * You should have received a copy of the GNU General Public License
30 * along with this program. If not, see <http://www.gnu.org/licenses/>.
33 // Initialize database layer
34 $databaseInstance = NULL;
36 // Generate FQFN for the database layer
37 $fqfn = FrameworkConfiguration::getSelfInstance()->getConfigEntry('base_path') . 'inc/database/lib-' . FrameworkConfiguration::getSelfInstance()->getConfigEntry('db_type') . '.php';
39 // Load the database layer include
40 if (BaseFrameworkSystem::isReadableFile($fqfn)) {
45 ApplicationEntryPoint::app_exit(sprintf('[Main:] Database layer is missing! (%s) -> R.I.P.',
46 FrameworkConfiguration::getSelfInstance()->getConfigEntry('db_type')
53 // Prepare database instance
54 $connectionInstance = DatabaseConnection::createDatabaseConnection(DebugMiddleware::getSelfInstance(), $databaseInstance);
56 // Is the app variable there and valid?
58 if (is_object($app)) {
59 $app->setDatabaseInstance($connectionInstance);