you can now specify your own error handling function by changing DB::$error_handler
This commit is contained in:
@@ -1,4 +1,11 @@
|
||||
<?
|
||||
function new_error_callback($params) {
|
||||
global $error_callback_worked;
|
||||
|
||||
if (substr_count($params['error'], 'You have an error in your SQL syntax')) $error_callback_worked = 1;
|
||||
}
|
||||
|
||||
|
||||
class BasicTest extends SimpleTest {
|
||||
function __construct() {
|
||||
error_reporting(E_ALL);
|
||||
@@ -95,6 +102,15 @@ class BasicTest extends SimpleTest {
|
||||
$results = DB::query("SELECT * FROM accounts WHERE username!=%s", "Charlie's Friend");
|
||||
$this->assert(count($results) === 2);
|
||||
}
|
||||
|
||||
function test_5_error_handler() {
|
||||
global $error_callback_worked;
|
||||
|
||||
DB::$error_handler = 'new_error_callback';
|
||||
DB::query("SELET * FROM accounts");
|
||||
|
||||
$this->assert($error_callback_worked === 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user