本文整理汇总了PHP中DB_CONNECT::close方法的典型用法代码示例。如果您正苦于以下问题:PHP DB_CONNECT::close方法的具体用法?PHP DB_CONNECT::close怎么用?PHP DB_CONNECT::close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DB_CONNECT
的用法示例。
在下文中一共展示了DB_CONNECT::close方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
}
示例3: PRODUCTS
<?php
/*
* Following code will list all the products
*/
// include db connect class
require_once __DIR__ . '/db_connect.php';
// connecting to db
$db = new DB_CONNECT();
echo "init db : creation tables";
$sql = "CREATE TABLE IF NOT EXISTS PRODUCTS (\npid INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,\nname VARCHAR(100) NOT NULL,\nprice DECIMAL(10,2) NOT NULL,\ndescription TEXT,\ncreated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\nupdated_at timestamp NULL DEFAULT NULL\n)";
if ($db->query($sql) === TRUE) {
echo "Table Products created successfully";
} else {
echo "Error creating table: " . $db->error;
}
$db->close();
示例4: explode
$stock = $_GET["stock"];
if (isset($_SESSION['carro'])) {
$array_productes_old = explode(",", $_SESSION['carro']);
if (count(preg_grep("[" . $item . "/" . $nom_item . "]", $array_productes_old)) < $stock) {
/* Comprovem que no s'hagi afegit mes cops que stock hi ha! */
$_SESSION['carro'] = $_SESSION['carro'] . ",[" . $item . "/" . $nom_item . "]";
}
} else {
$_SESSION['carro'] = "[" . $item . "/" . $nom_item . "]";
}
$productes_afegits = array();
$carrito = "<ul>";
$array_productes = explode(",", $_SESSION['carro']);
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)) {
$nom_producte = substr($producte, strpos($producte, "/") + 1, strpos($producte, "]"));
$nom_producte = trim($nom_producte, "]");
$carrito .= "<li>" . $nom_producte . " (x" . count(preg_grep($producte, $array_productes)) . ")</li>";
$productes_afegits[] = $id_producte;
}
}
}
$carrito .= "</ul>";
$carrito .= "<a href=\"../controller/carrito.php\"><button id=\"button_comprar\">Comprar</button></a>";
echo $carrito;
}
$db->close($con);