Class DB {
var $link;
var $db;
var $host;
var $user;
var $passwd;
var $res;
var $table;
function e($f) {
if (mysql_errno()) {
// echo "Error in (".get_class($this)."->".$f."):: ".mysql_errno().": ".mysql_error()."\n";
return false;
}
return true;
}
function connect() {
$this->link = mysql_connect($this->host, $this->user, $this->passwd);
if ($this->db) {
mysql_select_db($this->db, $this->link);
}
return $this->e('connect');
}
function query($sql) {
$this->res = mysql_query($sql, $this->link);
return $this->e('query');
}
function fetch() {
$a = array();
while($r = mysql_fetch_object($this->res)) {
$a[] = $r;
}
return $a;
}
function fetchArray() {
//$a = array();
while($r = mysql_fetch_row($this->res)) {
$a[] = $r[0];
}
return $a;
}
function fetch_xml() {
$a = array();
$xml = "\r\n\r\n";
$xml .= "res)."\">\r\n";
while($r = mysql_fetch_assoc($this->res)) {
$xml .= "\r\n";
foreach($r as $k => $v) {
$xml .= "<".$k.">".$v."".$k.">\r\n";
}
$xml .= "\r\n";
}
$xml .= "\r\n";
$xml .= "\r\n";
return $xml;
}
function fetch_structure() {
$_sql = "SHOW fields FROM $this->db.$this->table";
$this->query($_sql);
return $this->fetch_xml();
}
function showTables() {
$_sql = "show tables FROM $this->db";
$this->query($_sql);
return $this->fetch();
}
function showTablesArray() {
$_sql = "show tables FROM $this->db";
$this->query($_sql);
return $this->fetchArray();
}
function showIndex($table) {
$_sql = "SHOW INDEX FROM $this->db.".$table;
$this->query($_sql);
return $this->fetch();
}
function fetchData() {
$_sql = "SHOW fields FROM $this->db.$this->table";
$this->query($_sql);
//return $_sql;
$this->res = $this->fetch();
return $this->res;
}
function free_results() {
mysql_free_result($this->res);
}
}
?>
Fatal error: Uncaught Error: Class 'DB' not found in /www/htdocs/nwk/admin/lib/sql.class.php:35
Stack trace:
#0 /www/htdocs/nwk/etc/init.php(43): SQL->__construct()
#1 /www/htdocs/nwk/var/loader.php(21): require_once('/www/htdocs/nwk...')
#2 /www/htdocs/index.php(12): require_once('/www/htdocs/nwk...')
#3 {main}
thrown in /www/htdocs/nwk/admin/lib/sql.class.php on line 35