Changed database access to PDO using prepared statements
This commit is contained in:
31
assetdel.php
31
assetdel.php
@@ -12,31 +12,18 @@ include("includes.php");
|
||||
$asset_id = sanitize($_GET['asset_id']);
|
||||
|
||||
include("header.php");
|
||||
|
||||
$query = "SELECT
|
||||
asset_name
|
||||
FROM
|
||||
asset
|
||||
WHERE
|
||||
asset_id=" . $asset_id;
|
||||
|
||||
$asset = $db->db_select($query);
|
||||
|
||||
// asset to delete
|
||||
$sth = $dbh->prepare("SELECT asset_name FROM asset WHERE asset_id=?");
|
||||
$sth->execute([$asset_id]);
|
||||
$smarty->assign("asset_id", $asset_id);
|
||||
$smarty->assign("asset_name", $asset[0]['asset_name']);
|
||||
$smarty->assign("asset_name", $sth->fetchColumn());
|
||||
|
||||
$query = "SELECT
|
||||
node_id,
|
||||
node_ip
|
||||
FROM
|
||||
node
|
||||
WHERE
|
||||
asset_id=" . $asset_id . "
|
||||
ORDER BY
|
||||
INET_ATON(node_ip)";
|
||||
|
||||
$nodes = $db->db_select($query);
|
||||
$smarty->assign("nodes", $nodes);
|
||||
// nodes to delete
|
||||
$sql = "SELECT node_id, node_ip FROM node WHERE asset_id=? ORDER BY INET_ATON(node_ip)";
|
||||
$sth = $dbh->prepare($sql);
|
||||
$sth->execute([$asset_id]);
|
||||
$smarty->assign("nodes", $sth->fetchAll(PDO::FETCH_ASSOC));
|
||||
|
||||
$smarty->display("assetdel.tpl");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user