Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Klasa w klasie (include)
wujek2009
post
Post #1





Grupa: Zarejestrowani
Postów: 350
Pomógł: 31
Dołączył: 23.05.2010

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


W pliku index.php tworzę główną klasę:
  1. require_once 'inc/class/main.class.php';
  2. $x = new torrent_Core();
  3. $x->__autoload(array(__FILE__, 'comment'));


A w klasie torrent_Core mam funkcje __autoload, która prezentuje się następująco:
  1. public function __autoload($action)
  2. {
  3. if ( strpos($action[0], 'torrents') AND $action[1] == 'comment' ) {
  4. require_once self::$inc_url.'classes/'.strtolower($action[1]).'.class'.self::EXT;
  5. require_once self::$inc_url.'model/'.strtolower($action[1]).'_model.class'.self::EXT;
  6.  
  7. $inc_base = new ucfirst($action[1]).'_Core';
  8. $inc_model = new ucfirst($action[1]).'_Model';
  9.  
  10. } else {
  11. require_once self::$inc_url.'model/main_model.class'.self::EXT;
  12.  
  13. $inc_model = new Main_Model;
  14. }
  15. }


Jaki jest cel tego? - Oddzielenie głównych funkcji, od tych mniejszych oraz dołączenie modelu (zapytań sql), ale teraz w klasie torrent_Core próbuje się odwołać do funkcji z Main_Model (nazwa: loadSettings_model), ale dostaje komunikat:

Kod
Call to undefined method torrent_Core::loadSettings_model()


Próbowałem wywołać loadSettings_model za pomocą:
  1. $this->loadSettings_model();


Spróbowałem również w ten sposób:
  1. $inc_model->loadSettings_model();
  2.  
  3. błąd: Call to a member function loadSettings_model()


i najgorsze, że gdy wezmę var_dump($inc_model) w funkcji to otrzymuje NULL - czyli w ogóle __autoload nie przekazuje mi dalej klasy.

A tak prezentuje się klasa "Main_Model" - http://wklej.org/hash/99da31d9b1a/

Ten post edytował wujek2009 11.09.2010, 09:15:50
Go to the top of the page
+Quote Post

Posty w temacie
- wujek2009   Klasa w klasie (include)   11.09.2010, 09:15:10


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

 



RSS Aktualny czas: 4.10.2025 - 16:56