forked from eatvio/eatvio-infra
65 lines
1.6 KiB
PHP
65 lines
1.6 KiB
PHP
<?
|
|
$mysqli_server="tvtok.mysql";
|
|
$mysqli_login="tvtok_optimus";
|
|
$mysqli_password="dMfeus43rthjs";
|
|
$mysqli_db="tvtok_rent";
|
|
|
|
|
|
|
|
$db=@mysqli_connect($mysqli_server,$mysqli_login,$mysqli_password,$mysqli_db);
|
|
if (mysqli_connect_errno()) {
|
|
die("Can't connect to DB!");
|
|
}
|
|
|
|
mysqli_set_charset($db, "utf8");
|
|
|
|
function getmicrotime(){
|
|
list($usec, $sec) = explode(" ",microtime());
|
|
return ((float)$usec + (float)$sec);
|
|
}
|
|
|
|
if (!function_exists("mysqli_result")) {
|
|
function mysqli_result($res, $row, $field=0) {
|
|
if (!is_object($res)) return false;
|
|
$res->data_seek($row);
|
|
$datarow = $res->fetch_array();
|
|
return $datarow[$field];
|
|
}
|
|
}
|
|
|
|
if (!function_exists("mq")) {
|
|
function mq($db,$query,$critical=true,$output=true) {
|
|
if (DEBUG_SQL) {
|
|
global $debug_sql;
|
|
static $debug_cnt,$debug_time;
|
|
$debug_cnt++;
|
|
}
|
|
if (DEBUG_SQL) { $time_start = getmicrotime(); }
|
|
$q=mysqli_query($db,$query);
|
|
if (DEBUG_SQL) {
|
|
$bt=debug_backtrace();
|
|
$t=getmicrotime()-$time_start;
|
|
$debug_time+=$t;
|
|
$debug_sql.="--- ".$bt[0]['file']." [".$bt[0]['line']."]: ---\n<br>\n".$query."\n<br>\n".sprintf("%.6f",$t)." s.\n<br>\nTotal ".$debug_cnt." q. / ".sprintf("%.3f",$debug_time)." s.\n<br>\n";
|
|
}
|
|
if (!$q) {
|
|
if ($output) {
|
|
$bt=debug_backtrace();
|
|
echo $bt[0]['file']." [".$bt[0]['line']."]:\n<br>\n".mysqli_errno($db)." - ".mysqli_error($db)."\n<br>\n".$query."\n<br>\n";
|
|
}
|
|
if ($critical) die;
|
|
}
|
|
return $q;
|
|
}
|
|
}
|
|
|
|
if (!function_exists("mre")) {
|
|
function mre($db,$str) {
|
|
return mysqli_real_escape_string($db, $str);
|
|
}
|
|
}
|
|
|
|
setlocale(LC_CTYPE,"ru_RU.UTF-8");
|
|
mb_internal_encoding("UTF-8");
|
|
mb_regex_encoding("UTF-8");
|
|
?>
|