예제 #1
0
<?php

set_exception_handler('gwc_exception_handler');
# Centralised Web controller - all sites will have $GWC available to them
$directory_path = str_replace('controllers', '', __DIR__);
include_once $directory_path . 'classes/green_web_controller.php';
try {
    $GWC = new green_web_controller();
    $GWC->handleRequest();
} catch (Exception $ex) {
    die('need an elegant way of handling this - hard coded template or somming, etc [' . $ex . ']');
}
function gwc_exception_handler($exception)
{
    die('Unhandled exception caught. Need an elegant way of handling this - hard coded template or somming, etc [' . $exception->getMessage() . ']');
}
예제 #2
0
 public function testDatabaseRollback()
 {
     $GWC = new green_web_controller($debug = true);
     $GWC->handleRequest(array('database' => true));
     // Make sure this doesn't exist before doing any further tests
     $rs = $GWC->DBWrite('DROP TABLE IF EXISTS user_test');
     $this->assertEquals($rs, true);
     $rs = $GWC->DBWrite('CREATE TABLE IF NOT EXISTS user_test (id int PRIMARY KEY auto_increment,name varchar(64) NOT NULL,value varchar(64) NOT NULL,last_updated datetime NOT NULL) CHARACTER SET utf8;');
     $this->assertEquals($rs, true);
     $GWC->DBStartTransaction();
     $rs = $GWC->DBWrite('INSERT INTO user_test (name,value,last_updated) VALUES (:name, :value, NOW())', array(':name' => 'Green Framework Author', ':value' => "Adrian Green"));
     $this->assertEquals($rs, true);
     $GWC->DBRollback();
     $rs = $GWC->DBRead('SELECT * FROM user_test WHERE value = :value', array(':value' => 'Adrian Green'));
     $this->assertEmpty($rs);
     $rs = $GWC->DBWrite('DROP TABLE IF EXISTS user_test');
     $this->assertTrue($rs);
 }