ORM::configure('password', $config['database_password']); $db = ORM::get_db(); // enable query logging ORM::configure('logging', true); Flight::set('db', $db); Flight::set('dbname', $database); $stmt = $db->query("SHOW TABLES FROM " . Flight::get('dbname')); $data = $stmt->fetchAll(PDO::FETCH_NUM); $data = arrayFlatten($data); // create table names json file $json = array(); foreach ($data as $datakey => $datavalue) { $json[]['word'] = $datavalue; } @file_put_contents('tables.json', json_encode($json)); $tables = Presenter::listTables($data); Flight::set('tables', $tables); if (false !== strpos($_SERVER['REQUEST_URI'], '/table')) { $currentTableKey = array_search(Flight::get('lastSegment'), $data, true); unset($data[$currentTableKey]); // remove current table // make dropdown options Flight::set('tablesOptions', getOptions($data)); } // get an array of databases $stmt = $db->query("SHOW DATABASES"); $data = $stmt->fetchAll(PDO::FETCH_NUM); $data = arrayFlatten($data); Flight::set('databaseOptions', getOptions($data, true, null, $database)); // setup custom 404 page Flight::map('notFound', function () {