class DBMysql {
var $Connected;
var $Connection;
function DBMysql($connection_string) {
$this->Connected = FALSE;
$pattern = '/^([\w\d]+)

[^\s]*)@([.\w\d]+);([\w\d]+)$/';
$matches = array();
if ( preg_match($pattern, $connection_string, $matches) != 0 ) {
array_shift($matches);
list($username, $password, $host, $database) = $matches;
if ( $c = @mysql_connect($host, $username, $password) ) {
if ( @mysql_select_db($database, $c) ) {
$this->Connected = TRUE;
$this->Connection = $c;
$this->Query("SET NAMES cp1251");
}
}
}
return($this->Connected);
}
function Close() {
@mysql_close($this->Connection);
$this->Connected = FALSE;
}
function Query($query) {
$args = func_get_args();
if ( sizeof($args)-1 != substr_count($query, '?') ) trigger_error('Wrong arguments count<br>' . $query, E_USER_ERROR);
$sql = "";
$q = 1;
while ( ($pos = strpos($query, '?')) !== FALSE ) {
$l = $query[$pos-1];
$r = $query[$pos+1];
if ( $l == $r ) {
switch ($l) {
case '"':
$args[$q] = str_replace('"', '\"', $args[$q]);
break;
case '\'':
$args[$q] = str_replace('\'', '\\\'', $args[$q]);
break;
case '`':
$args[$q] = preg_replace('/[^a-zA-Z0-9_]/', '' , $args[$q]);
break;
}
}
else if ( !is_numeric($args[$q]) )
$args[$q] = '\'' . str_replace('\'', '\\\'', $args[$q]) . '\'';
$sql .= substr($query, 0, $pos) . $args[$q];
$query = substr($query, $pos+1, strlen($query)-$pos);
$q++;
}
$sql .= $query;
// echo $sql . '<hr>';
$result = mysql_query($sql, $this->Connection) or trigger_error('<b>Ошибка SQL запроса:</b> ' . $sql . '<br />' . mysql_error(), E_USER_ERROR);
return($result);
}
function Fetch($result) {
$row = @mysql_fetch_array($result);
return($row);
}
function FetchQuery($query) {
$args = func_get_args();
$result = call_user_func_array(array(&$this, 'Query'), $args);
$row = $this->Fetch($result);
return($row);
}
function FetchAll($result) {
$r = array();
while ( $row = $this->Fetch($result) ) $r[] = $row;
return($r);
}
function NumRows($result) {
$n = @mysql_num_rows($result);
return($n);
}
function IsEmpty($result) {
$result = ( $this->NumRows($result) == 0 ) ? TRUE : FALSE;
return($result);
}
function LastInsertID() {
return(mysql_insert_id($this->Connection));
}
}
$dbtable = array();
foreach (explode(',', $tablenames) as $tablename) {
$tablename = trim($tablename);
$dbtable[$tablename] = $db_prefix . $tablename;
}
$db = new DBMysql($DB_CONNECTION_STRING);
?>
Просмотрел,поискал,не понял:Р Что там должно быть такое,что меня так сильно интересует )))))