Witam
Mam taką klasę obsługi bazy danych:
<?php
class db {
const CACHE_DIR = './sql_cache/';
public $connect_id;
public $db_name;
public $query_result;
public $zapytan;
public $cache_file;
public $cache_stan;
public $cache_bufor;
public function __construct($db_host, $db_user, $db_pass, $db_name)
{
$this -> connect_id
= @mysql_connect($db_host, $db_user, $db_pass);
if($this -> connect_id)
{
if(!$this -> dbname)
{
$this -> _error('dbselect');
return false;
}
else
{
$this -> db_name = $db_name;
return true;
}
}
else
{
$this -> _error('connect');
return false;
}
}
public function sql_cache( $handle = 0 )
{
{
{
$this -> cache_stan = 1;
$this -> cache_file = CACHE_DIR.'cache_'.$handle.'cach';
}
else
{
$this -> cache_stan = 2;
$this -> cache_bufor
= array(); $this -> cache_file = CACHE_DIR.'cache_'.$handle.'cach';
}
}
else
{
if($this -> cache_stan == 2)
{
file_put_contents
($this -> cache_file
, serialize($this -> cache_bufor
)); }
$this -> cache_stan = 0;
}
}
public function sql_drop_cache( $handle )
{
{
unlink(CACHE_DIR
.'cache_'.$handle.'cach'); }
}
public function query($query)
{
if($this -> cache_stan != 1)
{
$this -> query_result = '';
$this -> query_result
= @mysql_db_query($this -> db_name
, $query, $this -> connect_id
);
if(!$this -> query_result)
{
$this -> _error('query');
return false;
}
else
{
$this -> zapytan++;
return true;
}
}
}
public function fetch_row($query_result='')
{
$query_result = (empty($query_result)) ?
$this -> query_result
: $query_result; if($this -> cache_stan == 1)
{
if(empty($this -> cache_bufor
)) {
return 0;
}
$array = $this -> cache_bufor;
}
else
{
if($this -> cache_stan == 2)
{
$this -> cache_bufor[] = $array;
}
}
if(!$array)
{
return false;
}
else
{
return $array;
}
}
public function num_rows($query_result='')
{
$query_result = (empty($query_result)) ?
$this -> query_result
: $query_result;
if(!$num_rows)
{
return false;
}
else
{
return $num_rows;
}
}
public function __destruct()
{
if(!$db_close)
{
$this -> _error('close');
return false;
}
else
{
return true;
}
}
public function _error($type)
{
$text = '<h1>MYSQL ERROR</h1>';
switch($type) {
case 'connect':
$text .= 'Wystąpił błąd podczas łączenia się z bazą danych!';
break;
case 'dbselect':
$text .= 'Wystąpił błąd podczas wybierania bazy danych!';
break;
case 'query':
$text .= 'Wystąpił błąd podczas wykonywania zapytania!';
break;
case 'close':
$text .= 'Wystąpił błąd podczas zamykania połączenia z bazą danych!';
break;
}
}
}
?>
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.

Siedze już nad tym 2 dni i nic.
WIELKIE DZIEKI ZA POMOC
Edit:///
Ok już sobie poradziłem

))))))))))))
Ten post edytował Apo 30.01.2006, 12:26:27