init
This commit is contained in:
commit
72a26edcff
22092 changed files with 2101903 additions and 0 deletions
86
mysql.class.php
Normal file
86
mysql.class.php
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
<?php
|
||||
|
||||
class mysql extends mysqli{
|
||||
private $querys = 0;
|
||||
|
||||
function insert($sql){
|
||||
$this->query($sql);
|
||||
return $this->insert_id;
|
||||
}
|
||||
|
||||
function query($sql){
|
||||
$return = parent::query($sql);
|
||||
if(!$return){
|
||||
trigger_error("Message: ".$this->error." (".$sql.")", E_USER_ERROR);
|
||||
}else{
|
||||
$this->querys++;
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
function query_single($sql){
|
||||
$out = $this->query($sql);
|
||||
$return = $out->fetch_assoc();
|
||||
$return['num_rows'] = $out->num_rows;
|
||||
return $return;
|
||||
}
|
||||
|
||||
function query_array($sql){
|
||||
$out_db = $this->query($sql);
|
||||
while($tmp = $out_db->fetch_assoc()){
|
||||
$out[] = $tmp;
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
function clean($sql){
|
||||
$sql = stripslashes($sql);
|
||||
$sql = $this->real_escape_string($sql);
|
||||
return $sql;
|
||||
}
|
||||
|
||||
function anzahl_querys(){
|
||||
return $this->querys;
|
||||
}
|
||||
|
||||
function get_last_id(){
|
||||
return $this->insert_id;
|
||||
}
|
||||
|
||||
function sql_backup(){
|
||||
$tables = $this->query("SHOW TABLES;");
|
||||
$backup = "Sicherung Datenbank \n\n";
|
||||
while($table = $tables->fetch_assoc()){
|
||||
$backup .= "INSERT INTO ".$table['Tables_in_'.CONFIG_MYSQL_DB]." () VALUES ";
|
||||
$daten = $this->query("SELECT * FROM ".$table['Tables_in_'.CONFIG_MYSQL_DB].";");
|
||||
$count_2 = 0;
|
||||
while($data = $daten->fetch_assoc()){
|
||||
if($count_2 == 1){
|
||||
$backup .= ",";
|
||||
}
|
||||
$backup .= "(";
|
||||
$count = 0;
|
||||
foreach($data as $dat){
|
||||
if($count == 1){
|
||||
$backup .= ",";
|
||||
}
|
||||
if($dat == ""){
|
||||
$backup .= "''";
|
||||
}else{
|
||||
$backup .= "'".$dat."'";
|
||||
}
|
||||
$count = 1;
|
||||
}
|
||||
$backup .= ")";
|
||||
$count_2 = 1;
|
||||
}
|
||||
$backup .= ";\n";
|
||||
}
|
||||
$x = fopen("tmp/dumpl.sql","w");
|
||||
fwrite($x,$backup);
|
||||
fclose($x);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue