Mam takie klasy:
<?php require_once("config.php"); public function __construct(){ $db = new PDO('mysql:host='.HOST.';dbname='.DB.'', USERNAME, PASSWORD); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } } public function shout($author, $shout){ $this->author = $author; $this->shout = $shout; //$stmt = $db->prepare("DELETE FROM isb_shouts WHERE sdate < ?"); //$stmt->bindValue(1, $this->olddata); //$stmt->execute(); $stmt = $db->prepare("INSERT INTO isb_shouts(sid, author, sdate, shout) VALUES(?, ?, ?, ?, ?)"); $stmt->bindValue(1, ''); $stmt->bindValue(2, $this->author); $stmt->bindValue(3, $this->data); $stmt->bindValue(4, $this->author); $stmt->execute(); } public function fetchshouts(){ $stmt = $db->prepare("SELECT * FROM isb_shouts"); $stmt->execute(); while($row = $stmt->fetch()){ if(EMOTICONS == 1){ $emot = $db->prepare("SELECT * FROM isb_emoticons"); $emot->execute(); while($emots = $emot->fetch()){ $emot_sign = $emots['emoticon_sign']; $emot_image = "<img src='".$emots['emoticon_image']."' />"; } } if(SBCODE == 1){ $sbcode = $db->prepare("SELECT * FROM isb_sbcode"); $sbcode->execute(); while($code = $sbcode->fetch()){ $code_sign = $sbcode['code']; $code_html = $sbcode['codehtml']; } } if(CENSURE == 1){ $censure = $db->prepare("SELECT * FROM isb_censore"); $censure->execute(); while($word = $censure->fetch()){ $word_tocensore = $word['word']; $word_replecement = $word['replacement']; } } } return $row['author']; return $row['sdate']; return $row['shout']; } } ?>
I teraz takie pytanie:
Jak wykorzystać $db w klasie dziedziczącej po mysql?? mam na myśli sb