Exemplo n.º 1
0
include_once "src/Router.php";
$router = new Router();
//URL rewriting
$task = explode('/', $_SERVER["REQUEST_URI"]);
//get the right route from the first parameter
$route = $router->getRoute($task[1]);
//get correct MVC bloc
$model = new $route->model();
$controller = new $route->controller($model);
$view = new $route->view($model);
require_once "src/util/regex.php";
//var_dump($task);
if (count($task) > 2) {
    $options = array_slice($task, 2);
    foreach ($options as $value) {
        if (empty($value) === false) {
            $controller->addOption(strip_all("/[^\\w]/", $value));
        }
    }
}
//let the controller update the model and the view display the model according to itself
//interruption by exception, for instance, inscription -> user already exists
try {
    $controller->update();
    $view->display();
} catch (exception $e) {
    echo $e->getMessage();
}
//close db connexion
$connexion->close();
$connexion = null;
Exemplo n.º 2
0
<?php

/**
 * Created by PhpStorm.
 * User: kevin
 * Date: 23/01/16
 * Time: 21:34
 */
include_once 'db_wrap.php';
include "/home/aaron-aaron/www/src/class/Twitter.php";
$bd = new \db\db_handler();
$bd->init();
$sql = "DELETE FROM TWEET";
$bd->query($sql);
$sql = "SELECT * FROM TWITTER";
$stmt = $bd->query($sql);
while ($result = $stmt->fetch()) {
    $newFlux = new Twitter($result['ID'], $result['NAME']);
    $newFlux->refresh();
}
$bd->close();