Файл: pesn_voini/peseni_vojni/instalscript/engine/cron/mess.php
Строк: 45
<?php
//
try{
$BaseConnect = new PDO("mysql:host=localhost;dbname=79910259319_test",'79910259319','tGn[2yzc4^x2');
}
catch(PDOException $e){
die('Нет соединения с базой данных!');
}
$BaseConnect->exec("set names utf8");
//
//Для обычного запроса
function cnt($sql, $params = array()) {
global $BaseConnect;
$stmt = $BaseConnect -> prepare($sql);
$stmt -> execute($params);
$stmt = $stmt->rowCount();
return $stmt;
}
//
//Работаем с базой данных
function qry($sql, $params = array()) {
global $BaseConnect;
$stmt = $BaseConnect -> prepare($sql);
$stmt -> execute($params);
return $stmt;
}
//
//Для вывода ассоциотивного массива
function fch($sql, $params = array()) {
global $BaseConnect;
$stmt = $BaseConnect -> prepare($sql);
$stmt -> execute($params);
$stmt = $stmt->fetch();
return $stmt;
}
//
$mess = fch("SELECT * FROM `mess_fight` WHERE `id` = ? LIMIT 1", array(1)); //проверяем запись в бд
//
qry("DELETE FROM `mess` WHERE `id` > ?", array(0));
qry("DELETE FROM `mess_log` WHERE `id` > ?", array(0));
//
if($mess['cron'] == 0){
qry("UPDATE `mess_fight` SET `time` = ?, `time_end` = ?, `users` = ?, `users_active` = ?, `id_leader` = ?, `id_ser` = ?, `cron` = ?, `fight` = ? WHERE `id` = ? LIMIT 1", array(time()+600,time()+3600*3,0,0,0,0,1,1,$mess['id']));
}
//
elseif($mess['cron'] == 1){
qry("UPDATE `mess_fight` SET `time` = ?, `time_end` = ?, `users` = ?, `users_active` = ?, `id_leader` = ?, `id_ser` = ?, `cron` = ?, `fight` = ? WHERE `id` = ? LIMIT 1", array(time()+600,time()+3600*3,0,0,0,0,2,1,$mess['id']));
}
//
//
elseif($mess['cron'] == 2){
qry("UPDATE `mess_fight` SET `time` = ?, `time_end` = ?, `users` = ?, `users_active` = ?, `id_leader` = ?, `id_ser` = ?, `cron` = ?, `fight` = ? WHERE `id` = ? LIMIT 1", array(time()+600,time()+3600*3,0,0,0,0,3,1,$mess['id']));
}
//
elseif($mess['cron'] == 3){
qry("UPDATE `mess_fight` SET
`time` = ?,
`time_end` = ?,
`users` = ?,
`users_active` = ?,
`id_leader` = ?,
`id_ser` = ?,
`cron` = ?,
`fight` = ?
WHERE `id` = ? LIMIT 1", array(
time()+600,
time()+3600*15,
0,
0,
0,
0,
0,
1,
$mess['id']));
}
//
?>