move to PDO and seperate config file
This commit is contained in:
parent
8afeb860c9
commit
aabb35f932
|
@ -0,0 +1,13 @@
|
|||
;<?php
|
||||
;die();
|
||||
;/*
|
||||
|
||||
dialect="mysql"
|
||||
host="localhost"
|
||||
user="web"
|
||||
password=""
|
||||
dbname="web"
|
||||
charset="utf8mb4"
|
||||
|
||||
;*/
|
||||
;?>
|
21
setup.php
21
setup.php
|
@ -1,13 +1,20 @@
|
|||
<?php
|
||||
|
||||
$conffile=parse_ini_file("config.ini.php");
|
||||
|
||||
$dsn=$conffile["dialect"].':host='.$conffile["host"].';dbname='.$conffile["dbname"].';charset='.$conffile["charset"];
|
||||
|
||||
$id=0;
|
||||
if(!is_null($_GET["id"]) and is_numeric($_GET["id"])){
|
||||
$id=$_GET["id"];
|
||||
$id=$_GET["id"];
|
||||
}
|
||||
$msql=new mysqli('localhost','web','','web');
|
||||
if($msql->connect_errno){
|
||||
die("connection error: ".$msql->connect_error);
|
||||
try{
|
||||
$pdo=new PDO($dsn,$conffile["user"],$conffile["password"]);
|
||||
}catch(\PDOException $e){
|
||||
throw new \PDOException($e->getMessage(), (int)$e->getCode());
|
||||
}
|
||||
$string="SELECT id,file,title,hover FROM comics ORDER BY CASE WHEN (id='$id') THEN 0 ELSE 1 END, id DESC";
|
||||
$qry=$msql->query($string) or die($msql->error);
|
||||
$comic=$qry->fetch_assoc();
|
||||
$string="SELECT id,file,title,hover FROM comics ORDER BY CASE WHEN (id=?) THEN 0 ELSE 1 END, id DESC";
|
||||
$qry=$pdo->prepare($string);
|
||||
$qry->execute([$id]);
|
||||
$comic=$qry->fetch(PDO::FETCH_ASSOC);
|
||||
?>
|
Loading…
Reference in New Issue