wbcmc/setup.php

20 lines
535 B
PHP

<?php
$conffile=parse_ini_file("config.ini.php");
$dsn=$conffile["dialect"].':'.$conffile["dsn"];
$id=0;
if(!is_null($_GET["id"]) and is_numeric($_GET["id"])){
$id=$_GET["id"];
}
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=?) THEN 0 ELSE 1 END, id DESC";
$qry=$pdo->prepare($string);
$qry->execute([$id]);
$comic=$qry->fetch(PDO::FETCH_ASSOC);
?>