0
0

Website refactored

Converted MySQLi Database.php class to PHP_PDO objects
This commit is contained in:
Bryan
2019-05-29 19:27:41 +02:00
parent 71e028cfdb
commit 63689ae0e9
5 changed files with 42 additions and 38 deletions

View File

@@ -7,21 +7,17 @@
$link_id = (int) $link_id;
$database = new Database ( $GLOBALS [ 'config' ] [ 'db' ] );
$database->connect ( );
$database->prepare ( "SELECT links.URL FROM links WHERE links.ID = ?" );
$parameters = [
[ "i" ],
[ &$link_id ],
];
$database->bind ( $parameters );
$database->prepare ( "SELECT links.URL FROM links WHERE links.ID = :link_id" );
$database->bind ( [ ':link_id' => $link_id ] );
$database->execute ( );
$result = $database->get_result ( );
$row = $result->fetch_assoc ( );
if ( ! $row ) {
if ( $result->rowCount ( ) == 0 ) {
http_response_code ( 404 );
include ( $GLOBALS [ 'config' ] [ 'installation_path' ] . '/lib/errors/404.html' );
exit;
}
else {
$row = $result->fetchAll ( ) [ 0 ];
?>
<!DOCTYPE html>
<html>