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 79 80
|
<?php
$KNOWLEDGEROOTDB = 'MYSQL';
class db {
var $connection = "";
var $dbtype = "mysqli";
function connect($host,$user,$pass,$db,$schema="",$encoding="") {
$this->connection = mysqli_connect($host,$user,$pass,$db);
if(!$this->connection) {
echo "Cannnot connect to host!\n";
exit();
}
/* not needed
$conndb = mysqli_select_db($db);
if(!$conndb) {
echo "Wrong Database!\n";
exit();
}
*/
return 1;
}
function close() {
mysqli_close($this->connection);
}
function lo_import($file) {
return 1;
}
function query($query) {
$res = mysqli_query($this->connection, $query);
if(!$res) {
echo "Error in QUERY: \"" . $this->error . "\"<br>\n";
echo "QUERY: \"$query\"<br>\n";
}
return $res;
}
function num_rows($result) {
$anz = mysqli_num_rows($result);
return $anz;
}
function fetch_object($result) {
$row = mysqli_fetch_object($result);
return $row;
}
function fetch_row($result) {
$row = mysqli_fetch_row($result);
return $row;
}
function fetch_assoc($result) {
$row = mysqli_fetch_assoc($result);
return $row;
}
function affected_rows($result) {
$anz = mysqli_affected_rows($result);
return $anz;
}
function error() {
return mysqli_error;
}
function last_id($name = "") {
return mysqli_insert_id();
}
}
?>
|