-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSimplaApp.php
40 lines (36 loc) · 925 Bytes
/
SimplaApp.php
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
31
32
33
34
35
36
37
38
39
40
<?php
include_once("config.php");
include_once("Lang.php");
class App
{
private static
$db = NULL,
$log = [];
public static function db($query = null)
{
global $config;
if(static::$db == NULL)
{
static::$db = mysqli_connect($config["db"]["host"], $config["db"]["username"], $config["db"]["password"], $config["db"]["database"]);
static::$db->query("SET NAMES utf8");
static::$db->query("SET time_zone = '+07:00'");
}
if($query === null) return static::$db;
$ret = static::$db->query($query);
if(static::$db->error)
{
$back = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1)[0];
App::log("Database error (in file $back[file] on line $back[line]) in query:\n«{$query}»\n<b>" . static::$db->error . "</b>");
}
return $ret;
}
public static function log($message)
{
static::$log[] = $message;
}
public static function logout()
{
return implode("\n", static::$log);
}
}
?>