Jestem początkujący w php5, Przeszukałem neta i znalazłem parę przydatnych rzeczy skleiłem je w całość w wyszła cała klasa. Jednak nie wiem czy jest ona dobrze napisana, mógł by mi to ktoś sprawdzić ? Poniżej załanczam klasę. Z góry dziękuje za pomoc.
<? # ---------------------------------------- # Sterownik bazy MySQL # ---------------------------------------- class Sql { public $cid; public $queries = 0; public $cache_state = 0; public $cache_file; public $cache_buffer; public $cache_ptr; public function __construct($host, $username, $password, $database) { $this -> cid = mysql_connect($host, $username, $password) or die ($this -> error("Problem z nawiazaniem polaczenia")); } // end __construct(); public function sqlClose() { } // end sqlClose(); public function sqlCache($handle = 0) { { { $this -> cache_state = 1; $this -> cache_ptr = 0; } else { $this -> cache_state = 2; $this -> cache_file = CACHE_DIR.'cache_'.$handle.'.sql'; } } else { if($this -> cache_state == 2) { } $this -> cache_state = 0; } } // end sql_cache(); public function sqlCacheRemove($handle) { { } } // end sql_cache_remove(); public function error($what = "Main System Error With Data Base") { return "<p style=\"color: red; font-weight: bold\">Driver SQL Problem <br>" . $what . " </p> ".mysql_error(); } // end error(); public function query($to_query, $query_name) { if($this -> cache_state != 1) { $this -> queries++; return 1; } } // end query(); public function numRows($query_name) { } // end numRows(); public function fetchRow($query_name) { if($this -> cache_state == 1) { { return 0; } $this -> rows = $this -> cache_buffer[$this -> cache_ptr]; $this -> cache_ptr++; return 1; } else { { if($this -> cache_state == 2) { $this -> cache_buffer[] = $this -> rows; } return 1; } } return 0; } // end fetchRow(); public function fetchAssoc($query_name) { if($this -> cache_state == 1) { { return 0; } $this -> rows = $this -> cache_buffer[$this -> cache_ptr]; $this -> cache_ptr++; return 1; } else { { if($this -> cache_state == 2) { $this -> cache_buffer[] = $this -> rows; } return 1; } } return 0; } // end fetchAssoc(); public function insertId() { } // edn insertId(); public function affectedRows() { } // end affectedRows(); public function fetchQuery($to_query, $query_name) { $this -> queries++; } // end fetchQuery(); } ?>