function truncate() { $ConnectionManager = new ConnectionManager(); $conn = $ConnectionManager->getConnection(); $stmt = $conn->prepare("TRUNCATE TABLE free_delivery_price"); $stmt->execute(); $ConnectionManager->closeConnection($stmt, $conn); }
function getUnusedCreditListByReceiverId($receiver_id) { $creditList = []; $ConnectionManager = new ConnectionManager(); $conn = $ConnectionManager->getConnection(); $stmt = $conn->prepare("SELECT sender_id, receiver_id FROM credit_history WHERE receiver_id = ? AND status = false"); $stmt->bind_param("s", $receiver_id); $stmt->execute(); $stmt->bind_result($sender_id, $receiver_id); while ($stmt->fetch()) { $credit = []; $credit["sender_id"] = $sender_id; $credit["receiver_id"] = $receiver_id; array_push($creditList, $credit); } $ConnectionManager->closeConnection($stmt, $conn); return $creditList; }
function updateSpecificPhoto($project_id, $photo_no, $new_url) { $url = self::getSpecificPhotoURL($project_id, $photo_no); unlink($url); $ConnectionManager = new ConnectionManager(); $conn = $ConnectionManager->getConnection(); $stmt = $conn->prepare("UPDATE photo SET photo_url=? WHERE project_id=? AND photo_no=?"); $stmt->bind_param("sss", $new_url, $project_id, $photo_no); $stmt->execute(); $ConnectionManager->closeConnection($stmt, $conn); }
function setGift($code, $product_name, $worth, $photo) { $ConnectionManager = new ConnectionManager(); $conn = $ConnectionManager->getConnection(); $stmt = $conn->prepare("UPDATE reward SET product_name = ? , worth = ? , photo = ? WHERE code = ?"); $stmt->bind_param("ssss", $product_name, $worth, $photo, $code); $stmt->execute(); $ConnectionManager->closeConnection($stmt, $conn); }
function deleteProject($project_id) { $ConnectionManager = new ConnectionManager(); $conn = $ConnectionManager->getConnection(); $stmt = $conn->prepare("DELETE FROM project WHERE project_id = ?"); $stmt->bind_param("s", $project_id); $stmt->execute(); $ConnectionManager->closeConnection($stmt, $conn); }
function deleteAllPhotosByProduct($product_id) { $photoList = self::getPhotos($product_id); foreach ($photoList as $url) { unlink($url); } $ConnectionManager = new ConnectionManager(); $conn = $ConnectionManager->getConnection(); $stmt = $conn->prepare("DELETE FROM photo WHERE product_id = ?"); $stmt->bind_param("s", $product_id); $stmt->execute(); $ConnectionManager->closeConnection($stmt, $conn); }
function getPostalCode($customer_id, $address_no) { $ConnectionManager = new ConnectionManager(); $conn = $ConnectionManager->getConnection(); $stmt = $conn->prepare("SELECT postal_code FROM address WHERE customer_id=? AND address_no=?"); $stmt->bind_param("si", $customer_id, $address_no); $stmt->execute(); $stmt->bind_result($postal_code); $postalcode = ''; while ($stmt->fetch()) { $postalcode = $postal_code; } $ConnectionManager->closeConnection($stmt, $conn); return $postalcode; }
function updateColorInOptionalCodeTable($product_id, $new_color, $old_color) { $ConnectionManager = new ConnectionManager(); $conn = $ConnectionManager->getConnection(); $stmt = $conn->prepare("UPDATE optional_code SET color = ? WHERE product_id = ? AND color = ?"); $stmt->bind_param("sss", $new_color, $product_id, $old_color); $stmt->execute(); $ConnectionManager->closeConnection($stmt, $conn); }
function checkProductPendingOrderStatus($product_id) { $result = 0; $ConnectionMgr = new ConnectionManager(); $conn = $ConnectionMgr->getConnection(); $stmt = $conn->prepare("SELECT COUNT(*) AS count FROM `order` where `product_id` = ? AND `status` = 'pending'"); $stmt->bind_param("s", $product_id); $stmt->execute(); $stmt->bind_result($count); while ($stmt->fetch()) { $result = $count; } $ConnectionMgr->closeConnection($stmt, $conn); return $result; }
function activateAccount($customer_id) { $verified = "true"; $ConnectionManager = new ConnectionManager(); $conn = $ConnectionManager->getConnection(); $stmt = $conn->prepare("UPDATE customer SET verified=? WHERE customer_id = ?"); $stmt->bind_param("ss", $verified, $customer_id); $stmt->execute(); $ConnectionManager->closeConnection($stmt, $conn); }