php require cms includes DbSimple Generic php function dbInit global c

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
require("cms/includes/DbSimple/Generic.php");
function dbInit() {
global $config;
$db = DbSimple_Generic::connect('mysql://'.$config['db']['user'].':'.$config['db']['password'].'@'.$config['db']['host'].'/'.$config['db']['dbname'].'');
$db->setIdentPrefix($config['db']['prefix']);
$db->setErrorHandler('dbExcept');
$db->setLogger('dbLogger');
$db->query("set names cp1251");
return $db;
}
function dbExcept($message, $info) {
echo "SQL Error: $message<br><pre>";
print_r($info);
echo "</pre>";
exit();
}
function dbLogger($db, $sql) {
//echo "<!--";
//print_r($sql);
//echo "-->";
}
?>