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


PHP DB_CONNECT::query_database方法代码示例

本文整理汇总了PHP中DB_CONNECT::query_database方法的典型用法代码示例。如果您正苦于以下问题:PHP DB_CONNECT::query_database方法的具体用法?PHP DB_CONNECT::query_database怎么用?PHP DB_CONNECT::query_database使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DB_CONNECT的用法示例。


在下文中一共展示了DB_CONNECT::query_database方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: create_table

 public static function create_table($name)
 {
     $query_string = "CREATE TABLE IF NOT EXISTS " . $name . "_users " . "(\n\t\t\t\t\t\t\t  `first_name` varchar(30) NOT NULL,\n\t\t\t\t\t\t\t  `last_name` varchar(30) NOT NULL,\n\t\t\t\t\t\t\t  `email` varchar(30) NOT NULL,\n\t\t\t\t\t\t\t  `phone_number` varchar(13) NOT NULL,\n\t\t\t\t\t\t\t  `score` int(11) NOT NULL DEFAULT '0',\n\t\t\t\t\t\t\t  `questions_attempted` int(11) NOT NULL DEFAULT '0',\n\t\t\t\t\t\t\t  `correct_ans` int(11) NOT NULL DEFAULT '0',\n\t\t\t\t\t\t\t  `wrong_ans` int(11) NOT NULL DEFAULT '0',\n\t\t\t\t\t\t\t  PRIMARY KEY (`email`),\n\t\t\t\t\t\t\t  UNIQUE KEY `phone_number` (`phone_number`)\n\t\t\t\t\t\t\t)";
     $db = new DB_CONNECT();
     $result = $db->query_database($query_string);
     return $result;
 }
开发者ID:abhik-setia,项目名称:MCQTECHNO,代码行数:7,代码来源:user.php

示例2: create_table

 public static function create_table($name)
 {
     $query_string = "CREATE TABLE IF NOT EXISTS " . $name . "_questions" . "(\n\t\t\t\t\t\t\t  `id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t\t\t  `question` text NOT NULL,\n\t\t\t\t\t\t\t  `option1` text NOT NULL,\n\t\t\t\t\t\t\t  `option2` text NOT NULL,\n\t\t\t\t\t\t\t  `option3` text NOT NULL,\n\t\t\t\t\t\t\t  `option4` text NOT NULL,\n\t\t\t\t\t\t\t  `correct_ans` text NOT NULL,\n\t\t\t\t\t\t\t  `marks` int(11) NOT NULL,\n\t\t\t\t\t\t\t  `negative_marks` int(11) NOT NULL,\n\t\t\t\t\t\t\t  PRIMARY KEY (`id`)\n\t\t\t\t\t\t\t)";
     $db = new DB_CONNECT();
     $result = $db->query_database($query_string);
     return $result;
 }
开发者ID:abhik-setia,项目名称:MCQTECHNO,代码行数:7,代码来源:question.php

示例3: urldecode

<?php

require_once "../includes/db_connect.php";
require_once "../includes/functions.php";
require_once "../includes/session.php";
confirm_logged_in();
if (!is_null($_GET['question_id'])) {
    $test_name = urldecode($_GET['test_name']);
    $question_id = $_GET["question_id"];
    $db = new DB_CONNECT();
    $username = get_username();
    //$test_name = $db->mysql_prep($_POST["test_name"]);
    $table_name = $test_name . "_questions";
    $query = "DELETE FROM " . $table_name . " WHERE id='{$question_id}'";
    $result = $db->query_database($query);
    if (is_null($result)) {
        // query failed
        echo "query failed";
    } else {
        redirect_to('question_list.php?test_name={$test_name}');
    }
}
开发者ID:abhik-setia,项目名称:MCQTECHNO,代码行数:22,代码来源:delete_question.php

示例4: while

<?php

require_once '../includes/db_connect.php';
require_once '../includes/functions.php';
require_once '../includes/session.php';
confirm_logged_in();
$db = new DB_CONNECT();
// get username from the session
$username = get_username();
//select all test created by him from test table
if (isset($_GET["message"])) {
    $message = "The Test has been deleted.";
}
$query = "SELECT test_name,start_time,end_time,event_date,duration FROM test WHERE username='{$username}'";
$admin_tests = $db->query_database($query);
if ($db->number_of_rows($admin_tests) > 0) {
    $i = 1;
    while ($row = $db->fetch_array($admin_tests)) {
        $table_data = array();
        $table_data_array[$i] = array();
        $table_data["test_name"] = $row["test_name"];
        $table_data["start_time"] = $row["start_time"];
        $table_data["end_time"] = $row["end_time"];
        $table_data["event_date"] = $row["event_date"];
        $table_data["duration"] = $row["duration"];
        $table_data_array[$i] = $table_data;
        $i++;
    }
    $no_of_rows = $i - 1;
    $table_data_array["number_of_rows"] = $no_of_rows;
    $table_html = make_test_information_table();
开发者ID:abhik-setia,项目名称:MCQTECHNO,代码行数:31,代码来源:view_test.php

示例5: array

            if (is_null($result)) {
                // query failed
                echo "query failed";
            } else {
                redirect_to("question_list.php?test_name=" . get_test_name());
            }
        } else {
            echo "empty fields";
        }
    } else {
        echo "Someting was not set";
    }
} else {
    $db = new DB_CONNECT();
    $query = "SELECT * FROM test WHERE test_name='" . get_test_name() . "' AND username='" . get_username() . "' ";
    $details = $db->query_database($query);
    if ($db->number_of_rows($details) > 0) {
        $i = 1;
        $row = $db->fetch_array($details);
        $table_data = array();
        $table_data["test_name"] = $row["test_name"];
        $table_data["start_time"] = $row["start_time"];
        $table_data["end_time"] = $row["end_time"];
        $table_data["event_date"] = $row["event_date"];
        $table_data["duration"] = $row["duration"];
    }
}
?>

<!DOCTYPE html>
<html>
开发者ID:abhik-setia,项目名称:MCQTECHNO,代码行数:31,代码来源:edit_test_details.php

示例6: urldecode

<?php

require_once '../includes/db_connect.php';
require_once '../includes/functions.php';
require_once '../includes/session.php';
confirm_logged_in();
$db = new DB_CONNECT();
// get username from the session
$username = get_username();
$test_name = urldecode($_GET['test_name']);
//select all test created by him from test table
$query = "SELECT * FROM " . $test_name . "_users";
$users_table = $db->query_database($query);
if ($db->number_of_rows($users_table) > 0) {
    $i = 1;
    while ($row = $db->fetch_array($users_table)) {
        $table_data = array();
        $table_data_array[$i] = array();
        $table_data["first_name"] = $row["first_name"];
        $table_data["last_name"] = $row["last_name"];
        $table_data["email"] = $row["email"];
        $table_data["phone_number"] = $row["phone_number"];
        $table_data["score"] = $row["score"];
        $table_data["questions_attempted"] = $row["questions_attempted"];
        $table_data["correct_ans"] = $row["correct_ans"];
        $table_data["wrong_ans"] = $row["wrong_ans"];
        $table_data_array[$i] = $table_data;
        $i++;
    }
    $no_of_rows = $i - 1;
    $table_data_array["number_of_rows"] = $no_of_rows;
开发者ID:abhik-setia,项目名称:MCQTECHNO,代码行数:31,代码来源:view_users_of_table.php

示例7: array

}
if (isset($_POST["submit"])) {
    $db = new DB_CONNECT();
    $keys = array("question", "option1", "option2", "option3", "option4", "radio", "marks", "negative_marks");
    if (!array_diff($keys, array_keys($_POST)) && check_is_set($_POST)) {
        $question = $db->mysql_prep($_POST["question"]);
        $option1 = $db->mysql_prep($_POST["option1"]);
        $option2 = $db->mysql_prep($_POST["option2"]);
        $option3 = $db->mysql_prep($_POST["option3"]);
        $option4 = $db->mysql_prep($_POST["option4"]);
        $correct_ans = $db->mysql_prep($_POST["radio"]);
        $marks = $db->mysql_prep($_POST["marks"]);
        $negative_marks = $db->mysql_prep($_POST["negative_marks"]);
        $table_name = get_test_name() . "_questions";
        $query = "Insert into " . $table_name . " (`question`, `option1`, `option2`, `option3`, `option4`, `correct_ans`, `marks`, `negative_marks`) \n       VALUES('{$question}','{$option1}','{$option2}', '{$option3}', '{$option4}', '{$correct_ans}', '{$marks}', '{$negative_marks}')";
        if (!is_null($db->query_database($query))) {
            redirect_to("add_question.php?message=true");
        } else {
            echo "Question cannot be added";
        }
    } else {
        $message = "Someting was not set";
    }
}
?>

<!DOCTYPE html>
<html>
   <head>
      <title>Add Question</title>
         <?php 
开发者ID:abhik-setia,项目名称:MCQTECHNO,代码行数:31,代码来源:add_question.php

示例8: urldecode

<?php

require_once "../includes/db_connect.php";
require_once "../includes/functions.php";
require_once "../includes/session.php";
confirm_logged_in();
if (!is_null($_GET['test_name'])) {
    $test_name = urldecode($_GET['test_name']);
    $db = new DB_CONNECT();
    $username = get_username();
    //$test_name = $db->mysql_prep($_POST["test_name"]);
    $query = "DELETE FROM test WHERE username='{$username}' AND test_name='{$test_name}'";
    $result = $db->query_database($query);
    if (is_null($result)) {
        // query failed
        echo "query failed";
    } else {
        $user_table = $test_name . "_users";
        $questions_table = $test_name . "_questions";
        $query = "DROP TABLE {$user_table} ";
        $result = $db->query_database($query);
        $query2 = "DROP TABLE {$questions_table} ";
        $result2 = $db->query_database($query2);
        var_dump($query2);
        if (!is_null($result) && !is_null($result2)) {
            redirect_to('view_test.php?message=true');
        }
    }
}
开发者ID:abhik-setia,项目名称:MCQTECHNO,代码行数:29,代码来源:delete_test.php


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