- Bemutatkozott a Motorola vékonymobilja
- iPhone topik
- Xiaomi 15 Ultra - kamera, telefon
- „Új mérce az Android világában” – Kezünkben a Vivo X300 és X300 Pro
- Fotók, videók mobillal
- Google Pixel topik
- iOS alkalmazások
- Xiaomi Mi 11 Ultra - Circus Maximus
- Felrobbant a Pixel Fold Zack Nelson kezében
- Android alkalmazások - szoftver kibeszélő topik
Új hozzászólás Aktív témák
-
trisztan94
őstag
Készítettem egy PDO kezelő osztályt.
<?php
class Database {
private $host = DB_HOST;
private $user = DB_USER;
private $pass = DB_PASS;
private $dbname = DB_NAME;
private $dbh;
private $error;
private $stmt;
public function __construct(){
$dsn = 'mysql:host=' . $this->host . ';dbname=' . $this->dbname;
$options = array(
PDO::ATTR_PERSISTENT => true,
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
);
try{
$this->dbh = new PDO($dsn, $this->user, $this->pass, $options);
}
catch(PDOException $e){
$this->error = $e->getMessage();
}
}
public function query($query){
$this->stmt = $this->dbh->prepare($query);
}
public function bind($param, $value, $type = null){
if (is_null($type)) {
switch (true) {
case is_int($value):
$type = PDO::PARAM_INT;
break;
case is_bool($value):
$type = PDO::PARAM_BOOL;
break;
case is_null($value):
$type = PDO::PARAM_NULL;
break;
default:
$type = PDO::PARAM_STR;
}
}
$this->stmt->bindValue($param, $value, $type);
}
public function execute(){
return $this->stmt->execute();
}
public function resultset(){
$this->execute();
return $this->stmt->fetchAll(PDO::FETCH_ASSOC);
}
public function single(){
$this->execute();
return $this->stmt->fetch(PDO::FETCH_ASSOC);
}
public function rowCount(){
return $this->stmt->rowCount();
}
public function lastInsertId(){
return $this->dbh->lastInsertId();
}
public function beginTransaction(){
return $this->dbh->beginTransaction();
}
public function endTransaction(){
return $this->dbh->commit();
}
public function cancelTransaction(){
return $this->dbh->rollBack();
}
public function debugDumpParams(){
return $this->stmt->debugDumpParams();
}
}
?>Parse error:
PHP Syntax Check: Parse error: syntax error, unexpected '{' in your code on line 36
if (is_null($type)) {Ez a bind() függvénynél van
Na én már vagy fél órája nézem a kódot, de nem látom, hogy hol rontottam el a szintaktikát
Ti láttok valamit?
Új hozzászólás Aktív témák
- Új Asus 16 ProArt 4K+ OLED Touch Ryzen AI 9 HX370 32GB 2TB Nvidia RTX 4060 8GB Studio Win11 Garancia
- REFURBISHED - DELL Performance Dock WD19DCS (210-AZBN)
- iPhone 13 128GB Pink -1 ÉV GARANCIA - Kártyafüggetlen, MS3430, 91% Akkumulátor
- ÁRGARANCIA!Épített KomPhone i5 14400F 32/64GB DDR5 RTX 5060 Ti 8GB GAMER PC termékbeszámítással
- HIBÁTLAN iPhone 12 mini 64GB Red -1 ÉV GARANCIA - Kártyafüggetlen, MS2036
Állásajánlatok
Cég: Promenade Publishing House Kft.
Város: Budapest
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest