本文整理汇总了PHP中DB_CONNECT类的典型用法代码示例。如果您正苦于以下问题:PHP DB_CONNECT类的具体用法?PHP DB_CONNECT怎么用?PHP DB_CONNECT使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DB_CONNECT类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: 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
示例2: 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
示例3: __construct
public function __construct()
{
$DB_CONNECT = new DB_CONNECT();
$this->connection = new \mysqli($DB_CONNECT->getHost(), $DB_CONNECT->getUsername(), $DB_CONNECT->getPassword(), $DB_CONNECT->getName());
if ($this->connection->connect_errno) {
echo "Failed to connect to MySQLI: " . $this->connection->connect_error;
}
}
开发者ID:RunningBear87,项目名称:API,代码行数:8,代码来源:MySQLI_DB.php
示例4: __construct
public function __construct()
{
try {
$DB_CONNECT = new DB_CONNECT();
$this->databaseConnection = mysql_connect($DB_CONNECT->getHost(), $DB_CONNECT->getUsername(), $DB_CONNECT->getPassword()) or die("Unable to connect to MySQL");
$this->selectedDatabase = mysql_select_db($DB_CONNECT->getDatabase(), $this->databaseConnection) or die("Could not select database");
} catch (Exception $error) {
echo 'Caught exception: ', $error->getMessage(), "\n";
}
}
开发者ID:RunningBear87,项目名称:tools,代码行数:10,代码来源:MySQL_DB.php
示例5: getProductes
function getProductes($id)
{
//Ens connectem a la base de dades
require_once '../db_connect.php';
/*Creem la connexió*/
$db = new DB_CONNECT();
$con = $db->connect();
$productes = array();
$sql = "SELECT * FROM nfc_producte WHERE Id_categoria='{$id}'";
$query = mysqli_query($con, $sql);
while ($producte = mysqli_fetch_assoc($query)) {
$productes[] = $producte;
}
return json_encode($productes);
$db->close($con);
}
开发者ID:jaumecolom,项目名称:Ecommerce,代码行数:16,代码来源:producte_categoria_model.php
示例6: getAllCategories
function getAllCategories()
{
//Ens connectem a la base de dades
require_once 'db_connect.php';
/*Creem la connexió*/
$db = new DB_CONNECT();
$con = $db->connect();
$categories = array();
$sql = "SELECT * FROM nfc_categoria ORDER BY id_categoria";
$query = mysqli_query($con, $sql);
while ($categoria = mysqli_fetch_assoc($query)) {
$categories[] = $categoria;
}
return json_encode($categories);
$db->close($con);
}
开发者ID:jaumecolom,项目名称:Ecommerce,代码行数:16,代码来源:menu_model.php
示例7: DB_CONNECT
<?php
//make database connection
require_once __DIR__ . '/db_connect.php';
$db = new DB_CONNECT();
$conn = $db->connect();
//initializing response array
$response = array();
//default city value for testing web without android post
$cityRetrived = "toronto";
//get post data city
if (isset($_GET["city"])) {
$cityRetrived = $_GET['city'];
require_once __DIR__ . '/APICalls.php';
//sql query for current conditions
$result2 = $conn->query("SELECT * FROM `currentConditions` WHERE city = '{$cityRetrived}'");
//check for empty data
if (!empty($result2)) {
if ($result2->num_rows > 0) {
//getting row array from database
$result2 = mysqli_fetch_array($result2);
//storing row into data arrary
$data = array();
$data["city"] = $result2["city"];
$data["temp"] = $result2["temp"];
$data["apparantTemp"] = $result2["apparantTemp"];
$data["summary"] = $result2["summary"];
$data["icon"] = $result2["icon"];
$data["time"] = $result2["time"];
$data["pressure"] = $result2["pressure"];
$data["dewPoint"] = $result2["dewPoint"];
开发者ID:TAR-O,项目名称:TUSK-Web,代码行数:31,代码来源:get_data.php
示例8: array
{
"phonenumber":"8950683510";
},
{
"phonenumber":"8950683512";
},
{
"phonenumber":"8950683543";
}
]
}
*/
require_once "includes/db_connect.php";
require_once "includes/functions.php";
$response = array();
$db = new DB_CONNECT();
// To count how many number are added in the table family
$count = 0;
if (isset($_POST["contacts"]) && isset($_POST["id"])) {
// fecthing the json string encoded from the url and decoding it into the json array
//$json = json_decode($_POST["contacts"],true);
$phonearrays = decode_JSON($_POST["contacts"]);
$id = $_POST["id"];
$number = array();
$response["phonenumbers"] = array();
foreach ($phonearrays as $number) {
// convert the number
$original_number = $number["phonenumber"];
if ($original_number[0] == '0') {
$number = substr($original_number, 1);
$original_number = "+91" . $number;
开发者ID:navneet1v,项目名称:Disaster-Safety,代码行数:31,代码来源:contact.php
示例9: DB_CONNECT
<?php
require_once $_SERVER['DOCUMENT_ROOT'] . '/db/db_connect.php';
if (isset($_POST["login"]) && isset($_POST["password"])) {
$db = new DB_CONNECT();
$login = $_POST["login"];
$password = $_POST["password"];
$response = array();
$login = $_POST["login"];
$result = $db->getConnection()->query("SELECT * FROM users WHERE login = '{$login}'");
if (!empty($result)) {
if ($result->num_rows > 0) {
$result = $result->fetch_array();
$salt = $result["salt"];
$hash = md5(md5($password . md5(sha1($salt))));
$iterations = 10;
for ($i = 0; $i < $iterations; ++$i) {
$hash = md5(md5(sha1($hash)));
}
if ($hash == $result["password"]) {
$response["success"] = 1;
$response["user"] = array();
$response["user"]["first_name"] = $result["first_name"];
$response["user"]["last_name"] = $result["last_name"];
} else {
$response["success"] = 0;
$response["salt"] = $salt;
$response["password"] = $hash;
$response["message"] = "Wrong password";
}
echo json_encode($response);
开发者ID:saegga,项目名称:DeLight-project,代码行数:31,代码来源:db_user_check.php
示例10: getTaulaProductsCarrito
function getTaulaProductsCarrito()
{
session_start();
$productes_afegits = array();
$carrito = "<table id=\"taula_carrito\">";
$array_productes = explode(",", $_SESSION['carro']);
$carrito .= "<tr>";
$carrito .= "<td id=\"fila_carrito\">";
$carrito .= "<p class=\"element_taula header_taula\">IMATGE</p>";
$carrito .= "</td>";
$carrito .= "<td id=\"fila_carrito\">";
$carrito .= "<p class=\"element_taula header_taula\">NOM</p>";
$carrito .= "</td>";
$carrito .= "<td id=\"fila_carrito\">";
$carrito .= "<p class=\"element_taula header_taula\">PREU (c/u)</p>";
$carrito .= "</td>";
$carrito .= "<td id=\"fila_carrito\">";
$carrito .= "<p class=\"element_taula header_taula\">PREU TOTAL</p>";
$carrito .= "</td>";
$carrito .= "<td id=\"fila_carrito\">";
$carrito .= "<p class=\"element_taula header_taula\">MODIFICAR</p>";
$carrito .= "</td>";
$quantitat_productes = 0;
$preu_total = 0;
foreach ($array_productes as $producte) {
if ($producte != "") {
$id_producte = substr($producte, 0, strpos($producte, "/"));
$id_producte = trim($id_producte, "[");
if (!in_array($id_producte, $productes_afegits)) {
//Ens connectem a la base de dades
require_once '../db_connect.php';
/*Creem la connexió*/
$db = new DB_CONNECT();
$con = $db->connect();
$sql = "SELECT * FROM nfc_producte WHERE id_producte = " . $id_producte . ";";
$query = mysqli_query($con, $sql) or die(mysqli_error($con));
$row = mysqli_fetch_array($query);
$carrito .= "<tr>";
$carrito .= "<td id=\"fila_carrito\">";
$carrito .= "<img class=\"element_taula\" width=\"100\" height=\"100\" src=\"../" . $row["URL_imatge"] . "\" onclick=\"removeFromCart(" . $id_producte . ")\"/>";
$carrito .= "</td>";
$carrito .= "<td id=\"fila_carrito\">";
$nom_producte = substr($producte, strpos($producte, "/") + 1, strpos($producte, "]"));
$nom_producte = trim($nom_producte, "]");
$carrito .= "<p class=\"element_taula\">" . $nom_producte . " (x" . count(preg_grep($producte, $array_productes)) . ")</p>";
$productes_afegits[] = $id_producte;
$carrito .= "</td>";
$quantitat_productes += count(preg_grep($producte, $array_productes));
$carrito .= "<td id=\"fila_carrito\">";
$carrito .= "<p class=\"element_taula\">" . $row["Preu_IVA"] . "</p>";
$carrito .= "</td>";
$carrito .= "<td id=\"fila_carrito\">";
$carrito .= "<p class=\"element_taula\">" . $row["Preu_IVA"] * count(preg_grep($producte, $array_productes)) . "</p>";
$carrito .= "</td>";
$preu_total += $row["Preu_IVA"] * count(preg_grep($producte, $array_productes));
$carrito .= "<td id=\"fila_carrito\">";
$carrito .= "<img class=\"element_taula\" src=\"../resources/img/delete-product.png\" onclick=\"borrar(" . $id_producte . ");\"/>";
$carrito .= "</td>";
$carrito .= "</tr>";
}
}
}
$carrito .= "<tr>";
$carrito .= "<td id=\"fila_carrito\">";
$carrito .= "<p class=\"element_taula header_taula\">TOTAL</p>";
$carrito .= "</td>";
$carrito .= "<td id=\"fila_carrito\">";
$carrito .= "<p class=\"element_taula\">" . $quantitat_productes . " unitats</p>";
$carrito .= "</td>";
$carrito .= "<td>";
$carrito .= "</td>";
$carrito .= "<td id=\"fila_carrito\">";
$carrito .= "<p class=\"element_taula\">" . $preu_total . " euros</p>";
$carrito .= "</td>";
$carrito .= "<td id=\"fila_carrito\">";
$carrito .= "<button class=\"element_taula\">CONFIRMAR</button>";
$carrito .= "</td>";
$carrito .= "</table>";
return $carrito;
}
开发者ID:jaumecolom,项目名称:Ecommerce,代码行数:80,代码来源:carrito_model.php
示例11: confirm_logged_in
<?php
require_once "/includes/session.php";
require_once "/includes/db_connect.php";
require_once "/includes/functions.php";
confirm_logged_in();
$db = new DB_CONNECT();
if (isset($_POST["calamity"]) && isset($_POST["before_cal"]) && isset($_POST["after_cal"]) && isset($_POST["during_cal"])) {
$calamity = trim($db->mysql_prep($_POST["calamity"]));
$before_cal = trim($db->mysql_prep($_POST["before_cal"]));
$after_cal = trim($db->mysql_prep($_POST["after_cal"]));
$during_cal = trim($db->mysql_prep($_POST["during_cal"]));
if (strlen($calamity) != 0 && strlen($before_cal) && strlen($after_cal) && strlen($during_cal)) {
$queryString = "INSERT INTO guidelines ( calamity , during_cal, after_cal , before_cal ) VALUES( '{$calamity}','{$during_cal}','{$after_cal}' ,'{$before_cal}') ";
echo $queryString;
$result = $db->query_db($queryString);
if ($result) {
//$_POST["message"] = "Inserted to the database";
redirect_to("guidelines.php?message=Inserted to the database");
} else {
echo "Cannot be inserted";
}
} else {
redirect_to("guidelines.php?message=Cannot be inserted. Some Values are Missing");
}
} else {
echo "Problem in the post request";
}
开发者ID:navneet1v,项目名称:Disaster-Safety,代码行数:28,代码来源:guidelinesToDataBase.php
示例12: array
/*
* Following code will create a new product row
* All product details are read from HTTP Post Request
*/
// array for JSON response
$response = array();
// check for required fields
if (isset($_POST['name']) && isset($_POST['price']) && isset($_POST['description'])) {
$name = $_POST['name'];
$price = $_POST['price'];
$description = $_POST['description'];
// include db connect class
require_once __DIR__ . '/db_connect.php';
// connecting to db
$db = new DB_CONNECT();
$con = $db->getConnection();
// mysql inserting a new row
$result = mysqli_query($con, "INSERT INTO products(name, price, description) VALUES('{$name}', '{$price}', '{$description}')") or die(mysqli_error($con));
// check if row inserted or not
if ($result) {
// successfully inserted into database
$response["success"] = 1;
$response["message"] = "Product successfully created.";
// echoing JSON response
echo json_encode($response);
} else {
// failed to insert row
$response["success"] = 0;
$response["message"] = "Oops! An error occurred.";
// echoing JSON response
开发者ID:TrongkhanhBkhn,项目名称:DaisyIT,代码行数:30,代码来源:create_product.php
示例13: array
<?php
/*
* Following code will list all the items
*/
// array for JSON response
$response = array();
// include db connect class
require_once __DIR__ . '/php_includes/DB_CONNECT.php';
// connecting to db
$db = new DB_CONNECT();
// get all items from item table
$result = mysqli_query($db->connect(), "SELECT *FROM item ORDER BY RAND()") or die(mysql_error());
// check for empty result
if (mysqli_num_rows($result) > 0) {
// looping through all results
// item node
$response["items"] = array();
while ($row = mysqli_fetch_array($result)) {
// temp user array
$item = array();
$item["idItem"] = $row["idItem"];
$item["sub_category"] = $row["sub_category"];
$item["category"] = $row["category"];
$item["shop"] = $row["shop"];
$item["user"] = $row["user"];
$item["item_name"] = $row["item_name"];
$item["price"] = $row["price"];
$item["item_image"] = $row["item_image"];
// push single product into final response array
array_push($response["items"], $item);
开发者ID:kenedyivan,项目名称:myrepo,代码行数:31,代码来源:get_all_items.php
示例14: DB_CONNECT
<?php
require_once __DIR__ . '/db_connect.php';
$db = new DB_CONNECT();
$output['deals'] = array();
$db->connect();
$q = mysql_query("SELECT * from deals");
while ($row = mysql_fetch_array($q)) {
$temp = array();
$temp['id'] = $row['id'];
$temp['name'] = $row['name'];
$temp['desc'] = $row['description'];
$temp['expire_time'] = $row['expire_time'];
$temp['brand_id'] = $row['brand_id'];
$temp['img'] = $row['image'];
array_push($output['deals'], $temp);
}
header('Content-Type: application/json');
print json_encode($output);
mysql_close();
开发者ID:rayedbajwa,项目名称:Privilege---Coupon-based-solution-for-codeigniter,代码行数:20,代码来源:getDeals.php
示例15: array
$response = array();
/*test data
* $username = 'otim';
* $email = '[email protected]';
* $password = '12345';
*/
// check for required fields
if (isset($_POST["username"]) && isset($_POST["email"]) && isset($_POST["password"]) && (!empty($_POST["username"]) && !empty($_POST["email"]) && !empty($_POST["password"]))) {
$username = $_POST["username"];
$email = $_POST["email"];
$password = $_POST["password"];
$date = date("Y-d-m");
// include db connect class
require_once __DIR__ . '/php_includes/DB_CONNECT.php';
// connecting to db
$db = new DB_CONNECT();
$connection = $db->connect();
// mysql inserting a new row
$result = mysqli_query($connection, "INSERT INTO user(username, email, password,date_joined) VALUES('{$username}', '{$email}', '{$password}','{$date}')");
$userId = mysqli_insert_id($connection);
// check if row inserted or not
if ($result) {
// successfully inserted into database
$response["userId"] = $userId;
$response["success"] = 1;
$response["message"] = "user registered successfully.";
// echoing JSON response
echo json_encode($response);
} else {
// failed to insert row
$response["success"] = 0;
开发者ID:kenedyivan,项目名称:myrepo,代码行数:31,代码来源:register_user.php
示例16: array
<?php
/*
* Following code will delete a job from table
* A job is identified by request id (jobid)
*/
// array for JSON response
$response = array();
// check for required fields
if (isset($_POST['jobid'])) {
// include db connect class
require_once __DIR__ . '/db_connect.php';
// connecting to db
$con = new DB_CONNECT();
$jobid = safe($con->getlink(), $_POST['jobid']);
// mysql update row with matched jobid
$result = mysqli_query($con->getlink(), "DELETE FROM roster WHERE jobid = '{$jobid}'");
// check if row deleted or not
if ($result) {
// successfully updated
$response["success"] = 1;
$response["message"] = "Job successfully deleted";
// echoing JSON response
echo json_encode($response);
} else {
// no job found
$response["success"] = 0;
$response["message"] = "No job found";
// echo no users JSON
echo json_encode($response);
}
开发者ID:arvind-web-developer,项目名称:csharp-projects-BIT-server-side-android-app,代码行数:31,代码来源:delete_job.php
示例17: json_decode
<?php
$_POST = json_decode(file_get_contents('php://input'), true);
if (isset($_POST["email"]) && isset($_POST['text'])) {
require_once __DIR__ . './db_connect.php';
$id = $_POST["email"];
$tweet = $_POST['text'];
//./db_connect file has class
$db = new DB_CONNECT();
$db_c = $db->connect();
$qry = $db_c->prepare("INSERT INTO tweets(idtemail,tweet) VALUES (?,?)");
// fist argument tells format of each parameter
$qry->bind_param("ss", $id, $tweet);
$qry->execute();
$qry->close();
$db_c->close();
} else {
echo "POST ELEMENTS NOT SET!";
}
开发者ID:umarhussain15,项目名称:web_ex5_twitter_feed_angular,代码行数:19,代码来源:setter.php
示例18: confirm_logged_in
<?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
示例19: confirm_logged_in
<?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
示例20: array
<?php
/*
* Following code will get single job details
* A job is identified by job id (jobid)
*/
// array for JSON response
$response = array();
// check for post data
if (isset($_GET['jobid'])) {
// include db connect class
require_once __DIR__ . '/db_connect.php';
// connecting to db
$con = new DB_CONNECT();
$jobid = safe($con->getlink(), $_GET['jobid']);
// get a job from products table
$result = mysqli_query($con->getlink(), "SELECT * FROM roster WHERE jobid = '{$jobid}'");
if (!empty($result)) {
// check for empty result
if (mysqli_num_rows($result) > 0) {
$row = mysqli_fetch_array($result);
$job = array();
$job["jobid"] = $row["jobid"];
$job["jobstatus"] = $row["jobstatus"];
$job["comments"] = $row["comments"];
// user node
$response["job"] = array();
array_push($response["job"], $job);
// success
$response["success"] = 1;
// echoing JSON response
开发者ID:arvind-web-developer,项目名称:csharp-projects-BIT-server-side-android-app,代码行数:31,代码来源:get_job_details.php
注:本文中的DB_CONNECT类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论