当前位置: 首页>>代码示例>>PHP>>正文


PHP Vote::update_in_db方法代码示例

本文整理汇总了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);
//.........这里部分代码省略.........
开发者ID:tttodorov13,项目名称:suSurvey,代码行数:101,代码来源:functions.php


注:本文中的Vote::update_in_db方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。