Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Problem z funkcjami klasy db w klasie cfg
morawcik89
post
Post #1





Grupa: Zarejestrowani
Postów: 56
Pomógł: 1
Dołączył: 15.07.2008

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


Mam taki oto problem:
- W pliku index.php inlcuduję pliki klas db (bazy) i get_cfg (config strony)
- Tworzę nowy obiekt klasy get_cfg i wywołuję funkcję cfg
- W contruct klasy get_cfg tworzę obiekt klasy db
- W funkcji cfg pobieram z bazy zawartość komórki theme
- Includuję pliki z folderu template/pobrana_wartość/

Przeglądarka zwraca błąd, że pliki template//... (... -> odpowiedni plik) nie istnieje

index.php
  1. <?
  2. $user = 'sys';
  3. if($_SESSION['user']) $user = $_SESSION['user'];
  4.  
  5. include 'class/db.class.php';
  6. include 'class/get_cfg.class.php';
  7.  
  8. $cfg = new get_cfg;
  9. $temp = $cfg->cfg($user);
  10.  
  11. include 'template/'.$temp.'/head.tpl';
  12. include 'template/'.$temp.'/register.tpl';
  13. include 'template/'.$temp.'/foot.tpl';
  14.  
  15. ?>

class/db.class.php
  1. <?
  2.  
  3. class db
  4. {
  5.  private $query = '';
  6.  private $connect = '';
  7.  private $db_name = '';
  8.  private $go_query = '';
  9.  
  10.  function __construct()
  11.  {
  12. $this->connect = $this->connect();
  13.  }
  14.  function __destruct()
  15.  {
  16. $this->close();
  17.  }
  18.  
  19.  private function connect()
  20.  {
  21. $db = parse_ini_file('config.ini', true);
  22. $this->connect = mysql_connect($db['mysql']['host'], $db['mysql']['user'], $db['mysql']['pass']);
  23. $this->db_name = $db['mysql']['name'];
  24. mysql_select_db($this->db_name);
  25.  }
  26.  
  27.  public function query($query)
  28.  {
  29. $this->query = $query;
  30.  }
  31.  
  32.  public function go_query()
  33.  {
  34. $this->go_query = mysql_query($this->query);
  35.  }
  36.  
  37.  public function assoc()
  38.  {
  39. return mysql_fetch_assoc($this->go_query);
  40.  }
  41.  
  42.  public function row()
  43.  {
  44. return mysql_fetch_array($this->go_query);
  45.  }
  46.  
  47. }
  48.  
  49. ?>

class/get_cfg.class.php
  1. <?
  2.  
  3. class get_cfg
  4. {
  5.  private $db = '';
  6.  
  7.  function __construct()
  8.  {
  9. $this->db = new db;
  10.  }
  11.  
  12.  public function cfg($user)
  13.  {
  14. $query = $this->db->query("SELECT * FROM cfg WHERE user = '$user'");
  15. $go = $this->db->go_query();
  16. $assoc = $this->db->assoc();
  17. $temp = $this->db->assoc['theme'];
  18. return $temp;
  19.  }
  20. }
  21.  
  22. ?>
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: 21.08.2025 - 22:25