Esempio n. 1
0
 public static function connect(array $connect)
 {
     self::$host = $connect['host'];
     self::$username = $connect['username'];
     self::$password = $connect['password'];
     self::$database = $connect['database'];
 }
Esempio n. 2
0
 public static function initDB()
 {
     if (!is_null(self::$database)) {
         return;
     }
     try {
         self::$database = new PDO('mysql:host=' . self::$MYSQL_HOST . ';dbname=' . self::$MYSQL_DB, self::$MYSQL_USER, self::$MYSQL_PWD, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8'"));
     } catch (Exception $e) {
         print 'Fatal error : Unable to connect to mysql database';
         exit(1);
     }
 }
Esempio n. 3
0
<?php

error_log(E_ALL);
define('ROOT', dirname(__FILE__) . '/');
include_once ROOT . 'DB.class.php';
include_once ROOT . '../helper/Debug.class.php';
include_once ROOT . '../Generator/Table.class.php';
include_once ROOT . 'DBTable.class.php';
$table = new Table(['class' => 'table']);
$dbh = new DB(DB::DB_NefaDB);
$database = $dbh->database();
$tables = $dbh->tables();
$tables = $tables[key($tables)];
$tableInfo = [];
?>
<!DOCTYPE HTML>
<html>
<head>
    <title>Database Analyse</title>
    <meta charset="UTF-8"/>
    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
    <style>
        .wrapper{
            width: 768px;
            margin: 50px auto;
        }
    </style>
</head>
<body>
    <div class="wrapper">
Esempio n. 4
0
include $lib_root . '/db_result.php';
include $lib_root . '/input.php';
include $lib_root . '/session.php';
include $lib_root . '/validation.php';
include $lib_root . '/model.php';
include $lib_root . '/controller.php';
include $lib_root . '/view.php';
// Initialize the application
Application::initialize();
Model::$root = $app_root . '/models';
Controller::$root = $app_root . '/controllers';
View::$root = $app_root . '/views';
// Database connectivity
DB::$adapter = "mysql";
DB::$host = "";
DB::$user = "";
DB::$password = "";
DB::$database = "";
DB::$adapter_root = $lib_root . '/db';
// Load the database adapter, will die() if not found
DB::load_adapter();
function __autoload($class)
{
    if (!Application::load($class)) {
        die("Could not locate class: {$class}");
    }
}
function __error_handler($errno, $errstr, $errfile = '', $errline = 0, $errcontext = array())
{
    print "<p>PHP Error: <strong>{$errstr}</strong> in <strong>{$errfile}</strong> at line <strong>{$errline}</strong>.</p>";
}