Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP][OOP] Dziwny błąd
sweter
post 21.09.2011, 09:53:37
Post #1





Grupa: Zarejestrowani
Postów: 623
Pomógł: 11
Dołączył: 1.01.2009
Skąd: Wrocław

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


Witam,
piszę klasę do cechowania w Zend Frameworku, jednak mam pewien problem. Klasa wygląda tak:
  1. class Application_Model_Cache
  2. {
  3.  
  4. // nazwa cache
  5. private $name;
  6. protected $frontendOptions;
  7. protected $backendOptions;
  8. public $cache;
  9.  
  10. public function __construct(){
  11. // opcje frontend
  12. $this->frontendOptions = array(
  13. 'lifetime' => null,
  14. 'automatic_serialization' => true
  15. );
  16.  
  17. // opcje backendu
  18. $this->backendOptions = array(
  19. 'cache_dir' => '../cache/'
  20. );
  21.  
  22. // cache
  23. $this->cache = Zend_Cache::factory('Core',
  24. 'File',
  25. $this->frontendOptions,
  26. $this->backendOptions);
  27. }
  28.  
  29. /**Metoda ustawiająca nazwę*/
  30. public function cacheSetName($name){
  31. $this->name = $name;
  32. }
  33.  
  34. /**Zwraca cache*/
  35. public function cacheGetData(){
  36. echo gettype($this->cache);
  37. }
  38.  
  39. /**Zapisuje cache*/
  40. public function cacheSaveData($data){
  41. echo gettype($this->cache);
  42. $this->cache->save($data, $this->name);
  43. }
  44.  
  45. /**Czyści cache*/
  46. public function cacheDelData(){
  47. echo gettype($this->cache);
  48. $this->cache->remove($this->name);
  49. }
  50.  
  51. }

Jak widać w metodach cacheDelData(), cacheSaveData() i cacheGetData() wywołuję funkcję gettype() z parametrem $this->cache;
Wszystko wywołuję tak:
  1. $cache = new Application_Model_Cache();
  2. $cache->cacheSetName('nazwa');
  3. $cache->cacheSaveData(array('d'));
  4. $cache->cacheGetData();
  5. $cache->cacheDelData();

Metody cacheSaveData() i cacheDelData() wyświetlają mi 'object', tylko cacheSaveData() zwraca mi NULL i 'object'.
O co może chodzić? Nie rozumiem dlaczego ta funkcja zwraca mi null i 'object'.
Co możecie poradzić?


--------------------
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 Wersja Lo-Fi Aktualny czas: 25.07.2025 - 09:14