mam oto takie cos:
<?php
define("PERSIST", 1);
define("TEMP", 0);
class MysqlDB
{
var $connection;
var $status;
var $login;
var $pass;
var $address;
var $database;
function MysqlDB($con_type = TEMP) {
require("confdb.php");
$this->address = $address;
$this->login = $login;
$this->pass = $pass;
$this->database = $db;
if ($con_type == TEMP) $this->connection = mysql_connect($this->address, $this->login, $this->pass);
else $this->connection = mysql_pconnect($this->address, $this->login, $this->pass);
if (!$this->connection) $this->status = mysql_error();
else {
if (mysql_select_db($this->database, $this->connection))
$this->status = "Connected to database ".$this->database;
else $this->status = mysql_error();
}
}
function is_connected() {
if ($this->connection != "") {
$this->status = "Connected";
return true;
}
else {
$this->status = "Not connected!";
return false;
}
}
function query ($qe,$one=0) {
$tmp = NULL;
if ($this->is_connected()) {
$tmp = mysql_query($qe, $this->connection);
if ($tmp) $this->status = "Query executed";
else $this->status = mysql_error();
if ($one == 1) {
$tmp = mysql_fetch_array($tmp);
list($key, $value) = each($tmp);
$tmp = $value;
}
}
return $tmp;
}
function query_numrows ($qer) {
$tmp = $this->query ($qer);
if ($tmp) return mysql_num_rows($tmp);
else return NULL;
}
function query_affected_rows ($qer) {
$this->query ($qer);
return mysql_affected_rows($this->connection);
}
function insert_id() {
return mysql_insert_id($this->connection);
}
function close() {
mysql_close($this->connection);
}
}
?>
wiem ze to jest funkcja, ale jak by sie ktos orientowal to o dokladnie jej wyjasnienie co robi itp. z gory dziekuje