Witam
Mam taką klasę obsługi bazy danych:

  1. <?php
  2. class db {
  3. const CACHE_DIR = './sql_cache/';
  4. public $connect_id;
  5. public $db_name;
  6. public $query_result;
  7. public $zapytan;
  8.  
  9. public $cache_file;
  10. public $cache_stan;
  11. public $cache_bufor;
  12.  
  13.     public function __construct($db_host, $db_user, $db_pass, $db_name)
  14.     {
  15.     $this -> connect_id = @mysql_connect($db_host, $db_user, $db_pass);
  16.  
  17.         if($this -> connect_id)
  18.         {
  19.         $this -> dbname = mysql_select_db($db_name);
  20.             if(!$this -> dbname)
  21.             {
  22.             $this -> _error('dbselect');
  23.             mysql_close($this -> connect_id);
  24.             return false;
  25.             }
  26.             else
  27.             {
  28.             $this -> db_name = $db_name;
  29.             return true;
  30.             }
  31.         }
  32.         else
  33.         {
  34.         $this -> _error('connect');
  35.         return false;
  36.         }
  37.     }
  38.     
  39.     public function sql_cache( $handle = 0 )
  40.     {
  41.         if(is_string($handle))
  42.         {
  43.             if(file_exists(CACHE_DIR.'cache_'.$handle.'cach'))
  44.             {
  45.             $this -> cache_stan = 1;
  46.             $this -> cache_file = CACHE_DIR.'cache_'.$handle.'cach';
  47.             $this -> cache_bufor[] = unserialize(file_get_contents($this -> cache_file));
  48.             }
  49.             else
  50.             {
  51.             $this -> cache_stan = 2;
  52.             $this -> cache_bufor = array();
  53.             $this -> cache_file = CACHE_DIR.'cache_'.$handle.'cach';
  54.             }
  55.         }
  56.         else
  57.         {
  58.             if($this -> cache_stan == 2)
  59.             {
  60.             file_put_contents($this -> cache_file, serialize($this -> cache_bufor));
  61.             }
  62.         $this -> cache_stan = 0;
  63.         }
  64.     }
  65.     
  66.     public function sql_drop_cache( $handle )
  67.     {
  68.         if(file_exists(CACHE_DIR.'cache_'.$handle.'cach'))
  69.         {
  70.         unlink(CACHE_DIR.'cache_'.$handle.'cach');
  71.         }
  72.     }
  73.     
  74.     public function query($query)
  75.     {
  76.     if($this -> cache_stan != 1)
  77.     {
  78.     $this -> query_result = '';
  79.     $this -> query_result = @mysql_db_query($this -> db_name, $query, $this -> connect_id);
  80.     
  81.         if(!$this -> query_result)
  82.         {
  83.         $this -> _error('query');
  84.         return false;
  85.         }
  86.         else
  87.         {
  88.         $this -> zapytan++;
  89.         return true;
  90.         }
  91.     }
  92.     }
  93.     
  94.     public function fetch_row($query_result='')
  95.     {
  96.     $query_result = (empty($query_result)) ? $this -> query_result : $query_result;
  97.     if($this -> cache_stan == 1)
  98.     {
  99.         if(empty($this -> cache_bufor))
  100.         {
  101.         return 0;
  102.         }
  103.     $array = $this -> cache_bufor;
  104.     }
  105.         else
  106.         {
  107.         $array = @mysql_fetch_array($query_result, MYSQL_ASSOC);
  108.             if($this -> cache_stan == 2)
  109.             {
  110.             $this -> cache_bufor[] = $array;
  111.             }
  112.         }
  113.  
  114.             if(!$array)
  115.             {
  116.             return false;
  117.             }
  118.             else
  119.             {
  120.             return $array;
  121.             }
  122.     }
  123.     
  124.     public function num_rows($query_result='')
  125.     {
  126.     $query_result = (empty($query_result)) ? $this -> query_result : $query_result;
  127.     $num_rows = @mysql_num_rows($query_result);
  128.     
  129.         if(!$num_rows)
  130.         {
  131.         return false;
  132.         }
  133.         else
  134.         {
  135.         return $num_rows;
  136.         }
  137.     }
  138.     
  139.     public function __destruct()
  140.     {
  141.     $db_close = @mysql_close($this -> connect_id);
  142.     
  143.         if(!$db_close)
  144.         {
  145.         $this -> _error('close');
  146.         return false;
  147.         }
  148.         else
  149.         {
  150.         return true;
  151.         }
  152.     }
  153.     
  154.     public function _error($type)
  155.     {
  156.     $text = '<h1>MYSQL ERROR</h1>';
  157.     
  158.     switch($type) {
  159.     case 'connect':
  160.     $text .= 'Wystąpił błąd podczas łączenia się z bazą danych!';
  161.     break;
  162.     
  163.     case 'dbselect':
  164.     $text .= 'Wystąpił błąd podczas wybierania bazy danych!';
  165.     break;
  166.     
  167.     case 'query':
  168.     $text .= 'Wystąpił błąd podczas wykonywania zapytania!';
  169.     break;
  170.     
  171.     case 'close':
  172.     $text .= 'Wystąpił błąd podczas zamykania połączenia z bazą danych!';
  173.     break;
  174.     }
  175.     
  176.     $text .= '<br />MYSQL says: <i>'.mysql_error().'</i>';
  177.     echo $text;
  178.     }
  179. }
  180. ?>


Próbowałem do tego dodać cachowanie zapytań. No i niby wszystko jest dobrze ale wogle mi nie tworzy pliku cache ;/ Myśle że problem jest w metodzie fetch_row ale nie wiem gdzie. sad.gif Siedze już nad tym 2 dni i nic.
WIELKIE DZIEKI ZA POMOC

Edit:///
Ok już sobie poradziłem smile.gif))))))))))))