1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
<?php
$KNOWLEDGEROOTDB = 'MYSQL';
class db {
var $connection = "";
var $dbtype = "mysql";
function connect($host,$user,$pass,$db,$schema="",$encoding="") {
$this->connection = mysql_connect($host,$user,$pass);
if(!$this->connection) {
echo "Cannnot connect to host!\n";
exit();
}
$conndb = mysql_select_db($db);
if(!$conndb) {
echo "Wrong Database!\n";
exit();
}
return 1;
}
function close() {
mysql_close($this->connection);
}
function lo_import($file) {
return 1;
}
function query($query) {
$res = mysql_query($query);
if(!$res) {
echo "Error in QUERY: \"" . $this->error . "\"<br>\n";
echo "QUERY: \"$query\"<br>\n";
}
return $res;
}
function num_rows($result) {
$anz = mysql_num_rows($result);
return $anz;
}
function fetch_object($result) {
$row = mysql_fetch_object($result);
return $row;
}
function fetch_row($result) {
$row = mysql_fetch_row($result);
return $row;
}
function fetch_assoc($result) {
$row = mysql_fetch_assoc($result);
return $row;
}
function affected_rows($result) {
$anz = mysql_affected_rows($result);
return $anz;
}
function error() {
return mysql_error;
}
function last_id($name = "") {
return mysql_insert_id();
}
}
?>
|