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

@@ -22,17 +22,13 @@
$database = new Database ( $GLOBALS [ 'config' ] [ 'db' ] );
$database->connect ( );
$url = $_POST [ 'url' ];
$database->prepare ( "INSERT INTO `links` ( `URL`, `created_by` ) VALUES ( ?, " . $_SESSION [ 'user_id' ] . " );" );
$parameters = [
[ "s" ],
[ &$url ],
];
$database->bind ( $parameters );
$database->prepare ( "INSERT INTO `links` ( `URL`, `created_by` ) VALUES ( :url, " . $_SESSION [ 'user_id' ] . " );" );
$database->bind ( [ ':url' => $url ] );
$database->execute ( );
$database->prepare ( "SELECT MAX( links.ID ) as `last` FROM links;");
$database->execute ( );
$result = $database->get_result ( );
$row = $result->fetch_assoc ( );
$row = $result->fetchAll ( ) [ 0 ];
header ( 'Content-Type: application/json' );
$response = [
'status' => 200,