本文整理汇总了PHP中Vote::update_in_db方法的典型用法代码示例。如果您正苦于以下问题:PHP Vote::update_in_db方法的具体用法?PHP Vote::update_in_db怎么用?PHP Vote::update_in_db使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vote
的用法示例。
在下文中一共展示了Vote::update_in_db方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: survey_funct
function survey_funct()
{
// get global user object
global $user;
// set connection var
global $db;
// get current time
$time_now = date("Y-m-d H:i:s");
// protect from unauthorized access
if (!isset($user) or !isset($_POST['formSurveyFunction'])) {
logout();
die;
}
// set empty survey
$session_survey = new Survey();
$session_survey = get_session_survey();
$survey_id = $_POST['formSurveyFunction'];
if ($survey_id != "") {
$session_survey->get_from_db($survey_id);
}
// get the function
$function = '';
foreach ($_POST as $key => $post) {
if ($post != $survey_id) {
$function = substr($key, 10);
}
}
if ($function == 'Print') {
$_SESSION['survey_id'] = $survey_id;
header('location: ' . ROOT_DIR . '?print=survey_print');
die;
} elseif ($function == 'Remove') {
if ($session_survey->getId() != NULL) {
//query to delete survey
$session_survey->setIsActive(0);
$session_survey->update_in_db();
}
$cookie_key = 'msg';
$cookie_value = 'Вие успешно изтрихте Ваша анкета!';
setcookie($cookie_key, $cookie_value, time() + 1);
header('Location: ' . ROOT_DIR . '?page=admin_survey');
die;
} elseif ($function == 'Reset') {
if (isset($_SESSION['session_survey'])) {
unset($_SESSION['session_survey']);
}
if (isset($_SESSION['session_groups'])) {
unset($_SESSION['session_groups']);
}
if (isset($_SESSION['session_answers'])) {
unset($_SESSION['session_answers']);
}
if (isset($_SESSION['session_question'])) {
unset($_SESSION['session_question']);
}
header('location: ' . ROOT_DIR . '?page=survey_edit');
die;
} elseif ($function == 'Edit') {
// check if post a survey id and asign
if (!isset($_POST['formSurveyFunction'])) {
// or go back
$cookie_key = 'msg';
$cookie_value = 'Не е избрана анкета!';
setcookie($cookie_key, $cookie_value, time() + 1);
header('Location: ' . ROOT_DIR . '?page=admin_survey');
die;
}
$session_survey->get_from_db(intval($_POST['formSurveyFunction']));
// check for illegal access
if ($session_survey->getCreatedBy() != $user->getId() && $user->getAdmin() != 1) {
error('Опит за неоторизиран достъп!');
$cookie_key = 'msg';
$cookie_value = 'Опит за неоторизиран достъп!';
setcookie($cookie_key, $cookie_value, time() + 1);
header('Location: ' . ROOT_DIR . '?page=admin_survey');
die;
}
$_SESSION['session_survey'] = serialize($session_survey);
$session_groups = array();
$session_groups['type'] = '';
$session_groups['student'] = get_survey_student_groups($session_survey->getId());
$session_groups['staff'] = get_survey_staff_groups($session_survey->getId());
$session_groups['local'] = get_survey_local_groups($session_survey->getId());
$_SESSION['session_groups'] = serialize($session_groups);
$cookie_key = 'msg';
$cookie_value = 'Вие избрахте анкета за редакция!';
setcookie($cookie_key, $cookie_value, time() + 1);
header('Location: ' . ROOT_DIR . '?page=survey_edit');
die;
} elseif ($function == 'Save') {
// check for answers
$session_answers = array();
$session_answers = get_session_answers();
$available_from = $_POST['formSurveyFromDate'] . " " . $_POST['formSurveyFromHour'] . ":00";
$available_due = $_POST['formSurveyDueDate'] . " " . $_POST['formSurveyDueHour'] . ":00";
$title = $_POST['formSurveyTitle'];
$status = $_POST['formSurveyStatus'];
$session_survey->setIsActive(1);
$session_survey->setCreatedOn($time_now);
$session_survey->setLastEditedOn($time_now);
//.........这里部分代码省略.........