Witam,
Uzywam na swojej stronie ponizszego sterownika MySQL:
<?php
function file_put_contents($plik, $dane) {
}
}
define('CACHE_DIR', './cache/');
class sql {
var $connection;
var $result;
var $rows;
var $queries = 0;
var $cache_mode; # 0 - disabled; 1 - enabled; 2 - enabled with generating cache file
var $cache_buffer;
var $cache_file;
var $cache_ptr;
function connect($host, $user, $pass, $db) {
$this->query("SET NAMES 'utf8'");
}
function __destruct() {
}
function cache_remove($handle) {
unlink(CACHE_DIR
.'%%_'.$handle.'.cch'); }
function cache($handle = 0) {
$this -> cache_mode = 1;
$this -> cache_ptr = 0;
}
else {
$this -> cache_mode = 2;
$this -> cache_buffer
= array(); $this -> cache_file = CACHE_DIR.'%%_'.$handle.'.cch';
}
} else {
if($this->cache_mode == 2) {
file_put_contents
($this->cache_file, serialize($this->cache_buffer)); }
$this->cache_mode = 0;
}
}
function num_rows() {
if($this->cache_mode == 1)
return count($this->cache_buffer); else
}
function query($query) {
if($this->cache_mode != 1) {
$this->queries++;
}
}
function sql_result() {
if($this->cache_mode == 1)
return count($this->cache_buffer); else
}
function fetch_array() {
if($this->cache_mode == 1) {
if(!isset($this->cache_buffer[$this->cache_ptr])) { return false;
}
$this->rows = $this->cache_buffer[$this->cache_ptr];
$this->cache_ptr++;
return true;
} else {
if($this->cache_mode == 2) {
$this->cache_buffer[] = $this->rows;
}
return true;
}
}
return false;
}
function close(){
if($plik != '.' && $plik != '..' && $plik != ".htaccess" && @filemtime(CACHE_DIR
.''.$plik) < $time){ }
}
}
}
?>
jakis czas temu wszystko jeszcze dzialalo. Nagle mu sie cos odwidzialo i nie wykonuje mi niektorych zapytan sql. Np takiego:
<?php
$sql->query("INSERT INTO f_ulubione SET id_id = '".$_GET['id']."', user = '".$_SESSION['uid']."', dodane = '".time()."'"); ?>
zapytania sa dobre, bo tak jak pisalem juz, wczesniej dzialaly. Teraz je dodatowo wyswietlalem i recznie wklepywalem do phpmyadmina i wszystko smiga.
Druga sprawa to, ze np. instrukcj $sql->num_rows(); zwraca mi wartosc 1, gdzie normalnie powinna zwrocic wartosc 0 :/ Troche mnie ta sytuacja irytuje, bo nie wiem co moze byc zle i gdzie mam szukac przyczyn bledu. Zaznaczam ze sterownik nie jest mojego autorstwa.
Ten post edytował batat 15.03.2008, 17:11:42