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


PHP DB_CONNECT::connect方法代码示例

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


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

示例1: 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

示例2: 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

示例3: json_encode

<?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

示例4: date

/*test data
* $username = 'otim';
* $email = 'otim@gmail.com';
* $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;
        $response["message"] = "Oops! An error occurred.";
开发者ID:kenedyivan,项目名称:myrepo,代码行数:31,代码来源:register_user.php

示例5: array

<?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

示例6: 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

示例7: array

<?php

// array for JSON response
$response = array();
// include db connect class
require_once __DIR__ . '/db_connect.php';
// connecting to db
$db = new DB_CONNECT();
// get all products from products table
$result = mysqli_query($db->connect(), "SELECT *FROM spt_user where userid=\"" . $_POST["userId"] . "\"");
// check for empty result
if (mysqli_num_rows($result) > 0) {
    // looping through all results
    // products node
    while ($row = mysqli_fetch_array($result)) {
        $response["username"] = $row["username"];
    }
    // success
    $response["success"] = 1;
    // echoing JSON response
    echo json_encode($response);
} else {
    $response["success"] = 0;
    $response["message"] = "No persons found";
    echo json_encode($response);
}
开发者ID:yuhancai,项目名称:okhttplearn,代码行数:26,代码来源:get_user_name.php

示例8: array

$response["errors"] = array();
if (isset($_POST["url"])) {
    if (preg_match('/\\s/', $_POST["url"])) {
    }
    require_once __DIR__ . '/db_connect.php';
    $_ID = $_SESSION["session_name"];
    $url = $_POST["url"];
    if ($url == "./maps" || $url == "./vizs") {
        $response["success"] = 1;
        $response["redirect"] = "./modules/" . stripslashes($url);
        echo json_encode($response);
        exit;
    }
    //    $url=addslashes($url);
    $db = new DB_CONNECT();
    $db_c = $db->connect("userdata");
    if ($url == "./p2p_ecommerce") {
        $qry = $db_c->prepare("SELECT * from hw_users where  user_id=?");
        // fist argument tells format of each parameter
        $qry->bind_param("s", $_ID);
        $qry->execute();
        $result = $qry->get_result();
        //    echo $_ID;
        if (mysqli_num_rows($result) == 1) {
            $row = mysqli_fetch_array($result);
            if ($row['isadmin'] == 1) {
                $_SESSION['hw_user_chk'] = 1;
            }
        }
    }
    $qry = $db_c->prepare("SELECT * from registered_modules where  user_id=? AND module_id=?");
开发者ID:umarhussain15,项目名称:web_semester_project_integration_repo_Jan16,代码行数:31,代码来源:openmodule.php

示例9: array

<?php

/*
 * Following code will list all the items
 */
// array for JSON response
$response = array();
if (isset($_GET["sub_cat_id"])) {
    $sub_cat_id = $_GET["sub_cat_id"];
    // 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 WHERE sub_category = '{$sub_cat_id}' 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["shop"] = $row["shop"];
            $item["user"] = $row["user"];
            $item["item_name"] = $row["item_name"];
            $item["price"] = $row["price"];
            $item["item_image"] = $row["item_image"];
            $item["item_description"] = $row["description"];
开发者ID:kenedyivan,项目名称:myrepo,代码行数:31,代码来源:get_subcategory_items.php

示例10: tweets

<?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

示例11: 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

示例12: array

<?php

/*
 * Following code will list all the items
 */
// array for JSON response
$response = array();
if (isset($_GET["sub_cat_id"]) && isset($_GET["item_id"])) {
    $sub_cat_id = $_GET["sub_cat_id"];
    $item_id = $_GET["item_id"];
    // 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 WHERE sub_category = '{$sub_cat_id}' AND idItem NOT IN ('{$item_id}') ORDER BY RAND() LIMIT 6") 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["shop"] = $row["shop"];
            $item["user"] = $row["user"];
            $item["item_name"] = $row["item_name"];
            $item["price"] = $row["price"];
            $item["item_image"] = $row["item_image"];
开发者ID:kenedyivan,项目名称:myrepo,代码行数:31,代码来源:get_related_items.php

示例13: array

<?php

/*
 * Following code will list all the items
 */
// array for JSON response
$response = array();
if (isset($_GET["cat_id"])) {
    $cat_id = $_GET["cat_id"];
    // 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 sub_category WHERE Category_idCategory= '{$cat_id}'") or die(mysql_error());
    // check for empty result
    if (mysqli_num_rows($result) > 0) {
        // looping through all results
        // item node
        $response["sub_category"] = array();
        while ($row = mysqli_fetch_array($result)) {
            // temp user array
            $sub_category = array();
            $sub_category["idSub_category"] = $row["idSub_category"];
            $sub_category["sub_category_name"] = $row["sub_category_name"];
            $sub_category["sub_cat_image"] = $row["sub_cat_image"];
            // push single product into final response array
            array_push($response["sub_category"], $sub_category);
        }
        // success
        $response["success"] = 1;
开发者ID:kenedyivan,项目名称:myrepo,代码行数:31,代码来源:sub_category.php

示例14: 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 category") or die(mysql_error());
// check for empty result
if (mysqli_num_rows($result) > 0) {
    // looping through all results
    // item node
    $response["category"] = array();
    while ($row = mysqli_fetch_array($result)) {
        // temp user array
        $category = array();
        $category["idCategory"] = $row["idCategory"];
        $category["category_name"] = $row["category_name"];
        $category["cat_image"] = $row["cat_image"];
        // push single product into final response array
        array_push($response["category"], $category);
    }
    // success
    $response["success"] = 1;
    // echoing JSON response
    echo json_encode($response);
开发者ID:kenedyivan,项目名称:myrepo,代码行数:31,代码来源:category.php

示例15: array

<?php

$response = array();
if (isset($_GET['id_user'])) {
    require '..\\db_connect.php';
    $db = new DB_CONNECT();
    $mysqli = $db->connect();
    $id_user = $_GET['id_user'];
    $result = $mysqli->query("SELECT *FROM purchase_history WHERE ID_USER= '{$id_user}' ") or die(mysql_error());
    if (mysqli_num_rows($result) > 0) {
        $response["purchase_history"] = array();
        while ($row = mysqli_fetch_array($result)) {
            $history = array();
            $history["ID"] = $row["ID"];
            $history["ID_PRODUCT"] = $row["ID_PRODUCT"];
            array_push($response["purchase_history"], $history);
        }
        $response["success"] = 1;
        echo json_encode($response);
    } else {
        $response["success"] = 0;
        $response["message"] = "No products found";
        echo json_encode($response);
    }
}
开发者ID:Toxa2033,项目名称:Buzalo,代码行数:25,代码来源:get_purchase_history.php


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