本文整理汇总了PHP中Vote::get_from_db方法的典型用法代码示例。如果您正苦于以下问题:PHP Vote::get_from_db方法的具体用法?PHP Vote::get_from_db怎么用?PHP Vote::get_from_db使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vote
的用法示例。
在下文中一共展示了Vote::get_from_db方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
//.........这里部分代码省略.........
示例2: foreach
echo ROOT_DIR . '?page=survey&funct=survey_submit';
?>
" method="POST">
<div class="ac">
<section class="clearfix prefix_2">
<?php
foreach ($answers as $answer_id) {
$answer = new Answer();
$answer->get_from_db($answer_id);
$vote = new Vote();
$vote_id = 0;
$user_vote_by_answer = array();
$user_vote_by_answer = get_user_vote_by_answer($user_id, $answer_id);
if (!empty($user_vote_by_answer)) {
$vote_id = $user_vote_by_answer[0];
$vote->get_from_db($vote_id);
}
?>
<label for = "formSurvey<?php
print_r($question->getId());
?>
Answer<?php
print_r($answer->getId());
?>
"><?php
print_r($answer->getValue());
?>
<small><?php
print_r($answer->getDescription());
?>
</small>