Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Potrzebuje małej pomocy z klasami
Raven1122
post
Post #1





Grupa: Zarejestrowani
Postów: 369
Pomógł: 2
Dołączył: 1.11.2010

Ostrzeżenie: (0%)
-----


Witam,

Mam takie klasy:

  1. <?php
  2. require_once("config.php");
  3. class mysql{
  4.  
  5. public function __construct(){
  6. $db = new PDO('mysql:host='.HOST.';dbname='.DB.'', USERNAME, PASSWORD);
  7. $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  8. }
  9.  
  10. }
  11.  
  12. class sb extends mysql{
  13.  
  14. public function shout($author, $shout){
  15. $this->author = $author;
  16. $this->shout = $shout;
  17. $this->data = date("Y-m-d H:i:s");
  18. $this->olddata = date("Y-m-d H:i:s", time()-7*24*60);
  19.  
  20. //$stmt = $db->prepare("DELETE FROM isb_shouts WHERE sdate < ?");
  21. //$stmt->bindValue(1, $this->olddata);
  22. //$stmt->execute();
  23.  
  24. $stmt = $db->prepare("INSERT INTO isb_shouts(sid, author, sdate, shout) VALUES(?, ?, ?, ?, ?)");
  25. $stmt->bindValue(1, '');
  26. $stmt->bindValue(2, $this->author);
  27. $stmt->bindValue(3, $this->data);
  28. $stmt->bindValue(4, $this->author);
  29. $stmt->execute();
  30. }
  31.  
  32. public function fetchshouts(){
  33. $stmt = $db->prepare("SELECT * FROM isb_shouts");
  34. $stmt->execute();
  35. while($row = $stmt->fetch()){
  36. if(EMOTICONS == 1){
  37. $emot = $db->prepare("SELECT * FROM isb_emoticons");
  38. $emot->execute();
  39.  
  40. while($emots = $emot->fetch()){
  41. $emot_sign = $emots['emoticon_sign'];
  42. $emot_image = "<img src='".$emots['emoticon_image']."' />";
  43. str_replace($emot_sign, $emot_image, $row['shout']);
  44. }
  45. }
  46. if(SBCODE == 1){
  47. $sbcode = $db->prepare("SELECT * FROM isb_sbcode");
  48. $sbcode->execute();
  49.  
  50. while($code = $sbcode->fetch()){
  51. $code_sign = $sbcode['code'];
  52. $code_html = $sbcode['codehtml'];
  53. str_replace($code_sign, $code_html, $row['shout']);
  54. }
  55. }
  56. if(CENSURE == 1){
  57. $censure = $db->prepare("SELECT * FROM isb_censore");
  58. $censure->execute();
  59.  
  60. while($word = $censure->fetch()){
  61. $word_tocensore = $word['word'];
  62. $word_replecement = $word['replacement'];
  63. str_replace($word_tocensore, $word_replecement, $row['shout']);
  64. }
  65. }
  66. }
  67. return $row['author'];
  68. return $row['sdate'];
  69. return $row['shout'];
  70. }
  71.  
  72. }
  73.  
  74.  
  75. ?>


I teraz takie pytanie:
Jak wykorzystać $db w klasie dziedziczącej po mysql?? mam na myśli sb
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 20.08.2025 - 07:38