예제 #1
0
function delete($table, $paramConditions)
{
    // Atribui a instrução SQL construida no método
    $sql = buildDelete($table, $paramConditions);
    $conn = dbConnect();
    extract($paramConditions);
    $id = antiInjection($id);
    $stmt = mysqli_prepare($conn, $sql);
    mysqli_stmt_bind_param($stmt, 'i', $id);
    if (!mysqli_stmt_execute($stmt)) {
        $return = false;
    } else {
        $return = true;
    }
    mysqli_stmt_close($stmt);
    dbClose($conn);
    return $return;
}
예제 #2
0
<?php

include_once "dbconnect.php";
include_once "query_builder.php";
//Get type (table to access)
$type = $_GET["type"];
//if there is no type, return error
if ($type == null) {
    echo "noTypeError";
} else {
    //Get connection to database
    $conn = db_connect();
    //if there is no connection returned, die
    if ($conn == null) {
        die("Connection error");
    }
    //Get SQL Query/Queries for $type
    $sql = buildDelete($type);
    //Query the database
    $result = mysqli_multi_query($conn, $sql);
    //If result is returned, signal a success
    if ($result) {
        echo "success";
    } else {
        echo "fail";
    }
    //Disconnect from database
    db_disconnect($conn);
}