sqlquery; } public function getType($type) { $ret=""; switch ($type) { CASE 16: $ret="BIT";break; CASE 1: $ret="TINYINT";break; CASE 1: $ret="BOOL";break; CASE 2: $ret="SMALLINT";break; CASE 9: $ret="MEDIUMINT";break; CASE 3: $ret="INTEGER";break; CASE 8: $ret="BIGINT";break; CASE 8: $ret="SERIAL";break; CASE 4: $ret="FLOAT";break; CASE 5: $ret="DOUBLE";break; CASE 246: $ret="DECIMAL";break; CASE 246: $ret="NUMERIC";break; CASE 246: $ret="FIXED";break; CASE 10: $ret="DATE";break; CASE 12: $ret="DATETIME";break; CASE 7: $ret="TIMESTAMP";break; CASE 11: $ret="TIME";break; CASE 13: $ret="YEAR";break; CASE 254: $ret="CHAR";break; CASE 253: $ret="VARCHAR";break; CASE 254: $ret="ENUM";break; CASE 254: $ret="SET";break; CASE 254: $ret="BINARY";break; CASE 253: $ret="VARBINARY";break; CASE 252: $ret="TINYBLOB";break; CASE 252: $ret="BLOB";break; CASE 252: $ret="MEDIUMBLOB";break; CASE 252: $ret="TINYTEXT";break; CASE 252: $ret="TEXT";break; CASE 252: $ret="MEDIUMTEXT";break; CASE 252: $ret="LONGTEXT";break; DEFAULT: $ret="UNKNOWN"; } return $ret; } public function getFlag($flag) { $ret=""; switch ($flag) { CASE 1: $ret="NOT_NULL_FLAG";break; CASE 2: $ret="PRI_KEY_FLAG";break; CASE 4: $ret="UNIQUE_KEY_FLAG";break; CASE 16: $ret="BLOB_FLAG";break; CASE 32: $ret="UNSIGNED_FLAG";break; CASE 64: $ret="ZEROFILL_FLAG";break; CASE 128: $ret="BINARY_FLAG";break; CASE 256: $ret="ENUM_FLAG";break; CASE 512: $ret="AUTO_INCREMENT_FLAG";break; CASE 1024: $ret="TIMESTAMP_FLAG";break; CASE 2048: $ret="SET_FLAG";break; CASE 32768: $ret="NUM_FLAG";break; CASE 16384: $ret="PART_KEY_FLAG";break; CASE 32768: $ret="GROUP_FLAG";break; CASE 65536: $ret="UNIQUE_FLAG";break; DEFAULT: $ret="UNKNOWN"; } return $ret; } public function getFormatted($eingabe, $typ, $length=-1, $decimals=-1) { $typklasse="string"; switch($typ) { case 16:$typklasse="ganzzahl";break; case 1:$typklasse="ganzzahl";break; case 9:$typklasse="ganzzahl";break; case 3:$typklasse="ganzzahl";break; case 8:$typklasse="ganzzahl";break; case 16:$typklasse="ganzzahl";break; case 13:$typklasse="ganzzahl";break; // YEAR case 4:$typklasse="kommazahl";break; case 5:$typklasse="kommazahl";break; case 246:$typklasse="kommazahl";break; case 10:$typklasse="datum";break; case 12:$typklasse="datum";break; case 7:$typklasse="datum";break; case 11:$typklasse="datum";break; //case 13:$typklasse="datum";break; default:$typklasse="string"; } if ($typklasse=="ganzzahl") { if ($eingabe=="") return ""; return number_format($eingabe, 0, '', ''); } if ($typklasse=="kommazahl") { if ($decimals<0) $decimals=2; return number_format($eingabe, 2, ',', ''); } // Date if ($typ==10) { if (strlen($eingabe)>2) { $ts=$this->mysqldateToTimestamp($eingabe); return date("d.m.Y",$ts); } else { return (""); } } // Datetime if ($typ==12) { if (strlen($eingabe)>2) { $ts=$this->mysqldateToTimestamp($eingabe); return date("d.m.Y H:i:s",$ts); } else { return (""); } } // Timestamp if ($typ==7) { if (strlen($eingabe)>2) { $ts=$this->mysqldateToTimestamp($eingabe); return date("d.m.Y H:i:s",$ts); } else { return (""); } } // Time if ($typ==11) { if (strlen($eingabe)>2) { $ts=$this->mysqldateToTimestamp($eingabe); return date("H:i:s",$ts); } else { return (""); } } //Text if ($typklasse=="string") { if (strlen($eingabe)>0) { $eingabe=str_replace("\\\"","\"", $eingabe); $eingabe=str_replace("\\'","'" , $eingabe); $eingabe=str_replace("\\\\","\\" , $eingabe); return $eingabe; } else { return (""); } } return $eingabe; } public function getDBFormatted($eingabe, $format="text") { if ($format=="text") { return "'" . mysqli_real_escape_string($this->connection, $eingabe) . "'"; } if ($format=="number") { $eingabe=str_replace(" ","",$eingabe); //$eingabe=str_replace(".","",$eingabe); $eingabe=str_replace(",",".",$eingabe); $zahlen=""; if (preg_match_all("/[0-9\.\-]+/", $eingabe, $matches)) $zahlen = implode("",$matches[0]); if (trim(str_replace(".","",$zahlen))=="") return "null"; return $zahlen; } if ($format=="date") { $eingabeteile=explode(".", $eingabe); if (count($eingabeteile)<3) return "null"; $jahr=$eingabeteile[2]; $monat=$eingabeteile[1]; $tag=$eingabeteile[0]; if (strlen($jahr)<4) { $jahr=intval($jahr); if ($jahr<30) { $jahr=$jahr+2000; } if ($jahr>=30 && $jahr<100) { $jahr=$jahr+1900; } while (strlen($jahr)<4) { $jahr="0" . $jahr; } } while (strlen($monat)<2) { $monat="0" . $monat; } while (strlen($tag)<2) { $tag="0" . $tag; } return "'$jahr-$monat-$tag'"; } } public function timestampToMysqldate($timestamp, $format="Y-m-d H:i:s") { return date($format,$timestamp); } public function mysqldateToTimestamp($date) { date_default_timezone_set("Europe/Berlin"); return strtotime($date); } public function formatMysqlDate($date) { $datumzeit=explode(" ", $date); $datum=$datumzeit[0]; $datum=explode("-", $datum); if (count($datum)!=3) return ""; $jahr=$datum[0]; $monat=$datum[1]; $tag=$datum[2]; /* $stunde=0; $minute=0; $sekunde=0; if (isset($datumzeit[1])) { $zeit=$datumzeit[1]; $zeit=explode(":", $zeit); if (count($zeit)>1) { $stunde=$zeit[0]; $minute=$zeit[1]; } if (count($zeit)>2) { $sekunde=$zeit[2]; } }*/ return ("$tag.$monat.$jahr"); } public function getNewInstance() { return new DBAccess($this->host, $this->database, $this->user, $this->pass); } public function __construct($host=NULL, $database=NULL, $user=NULL, $pass=NULL){ $this->host=$host; $this->database=$database; $this->user=$user; $this->pass=$pass; $this->connection = mysqli_connect($host,$user,$pass,$database); mysqli_set_charset($this->connection,$this->defaultcharset); //mysqli_select_db($database, $this->connection); } public function getError() { return mysqli_error($this->connection); } public function getLatestnr() { return $this->latestnr; } public function disconnect() { if (is_resource($this->connection)) mysqli_close($this->connection); } public function getColumns($tablename, $skipfields="", $type="plain") { $skipfields="," . $skipfields . ","; $this->query("SHOW COLUMNS FROM $tablename"); $fields=array(); while($row=$this->fetchRow()) { if(strpos($skipfields,",".$fieldname.",")===false) { if ($type=="plain") { $fields[]=$row["Field"]; } else { $fields[$row["Field"]]=$row; } } } return $fields; } public function getCurrentColumns($type="plain") { if($this->metadatas==null) return null; $ret=array(); foreach($this->metadatas as $metadata) { if($type=="plain") { $ret[]=$metadata->name; } else { $ret[$metadata->name]=$metadata; } } return $ret; } public function copy($tablename, $key, $set="") { $this->query("SHOW COLUMNS FROM $tablename"); $skip=",nr,crtuser,crtdate,crttime,chguser,chgdate,chgtime,"; $fields=""; while($row=$this->fetchRow()) { if(strpos($skip,",".$row["Field"].",")===false) { if($row["Key"]=="") { $fields.=$row["Field"] . ","; } } } if (strlen($fields)>2) { $fields=substr($fields,0,-1); } $this->query("INSERT INTO $tablename ($fields) SELECT $fields FROM $tablename WHERE nr=$key"); if ($this->getError()=="" && $this->latestnr!=0) { $neuenr=$this->latestnr; $jetzt=time(); $crtdate=$this->timestampToMysqldate($jetzt, "Y-m-d"); $crttime=$this->timestampToMysqldate($jetzt, "H:i:s"); $crtuser=(isset($_SESSION["usernr"])?$_SESSION["usernr"]:"null"); //$this->query("UPDATE $tablename SET crtdate='$crtdate', crttime='$crttime', crtuser=$crtuser WHERE nr=$neuenr"); if ($set!="") { $this->query("UPDATE $tablename SET $set WHERE nr=$neuenr"); } } } public function select($from, $fields="*", $where="", $group="", $order="", $limit="") { if ($where!="") { $where="WHERE $where"; } if ($group!="") { $group="GROUP BY $group"; } if ($order!="") { $order="ORDER BY $order"; } if ($limit!="") { $limit="LIMIT $limit"; } $select="SELECT $fields FROM $from $where $group $order $limit"; $this->query($select); } public function update($tablename, $set, $where) { $where="WHERE $where"; $jetzt=time(); $chgdate=$this->timestampToMysqldate($jetzt, "Y-m-d"); $chgtime=$this->timestampToMysqldate($jetzt, "H:i:s"); $chguser=(isset($_SESSION["usernr"])?$_SESSION["usernr"]:"null"); if (trim($set)=="") return; //$set="SET chguser=$chguser, chgdate='$chgdate', chgtime='$chgtime', " . $set; $set="SET " .$set; $update="UPDATE $tablename $set $where"; $this->query($update); } public function getInsertValue($name, $type="number", $source=null, $default="") { if($type=="number" && $default=="") $default=0; if($source==null) return $this->getDBFormatted($this->getFromArray($_POST,$name,$default),$type); else return $this->getDBFormatted($this->getFromArray($source,$name,$default),$type); } public function insertVals($tablename, $dbvals) { $set=""; $fields=""; $vals=""; $this->getSqlFromArray($dbvals, $set, $fields, $vals); $this->insert($tablename,$fields,$vals); } public function updateVals($tablename, $dbvals, $where) { $set=""; $fields=""; $vals=""; $this->getSqlFromArray($dbvals, $set, $fields, $vals); $this->update($tablename,$set,$where); } public function insert($tablename, $fields, $vals) { $jetzt=time(); $crtdate=$this->timestampToMysqldate($jetzt, "Y-m-d"); $crttime=$this->timestampToMysqldate($jetzt, "H:i:s"); $crtuser=(isset($_SESSION["usernr"])?$_SESSION["usernr"]:"null"); if (trim($fields)=="") return; //$fields.=", crtuser, crtdate, crttime"; //$vals.=", $crtuser, '$crtdate', '$crttime'"; $insert="INSERT INTO $tablename ($fields) VALUES ($vals)"; $this->query($insert); } public function query($query) { $this->metadatas=NULL; $this->latestnr=0; $this->result=mysqli_query($this->connection, $query); if(!$this->result) echo mysqli_errno($this->connection) . ": " . mysqli_error($this->connection) . ": ".$query."\n"; $this->latestnr=mysqli_insert_id($this->connection); $this->counter=NULL; $this->sqlquery=$query; if (is_object($this->result)) $this->metadatas=$this->result->fetch_fields(); return $this->result; } public function fetchRow($formatted=false) { if (!$formatted) { $row=mysqli_fetch_assoc($this->result); /* if ($row) { foreach($this->metadatas as $metadata) { if($row[$metadata->name]!=null && $row[$metadata->name]!='') $row[$metadata->name]=utf8_encode($row[$metadata->name]); } } */ return $row; } else { $row=mysqli_fetch_assoc($this->result); if ($row) { foreach($this->metadatas as $metadata) { $row[$metadata->name . "_original"]=$row[$metadata->name]; $row[$metadata->name]=$this->getFormatted($row[$metadata->name], $metadata->type, $metadata->length, $metadata->decimals); } } return $row; } } public function count() { if($this->counter==NULL && is_object($this->result)) { $this->counter=mysqli_num_rows($this->result); } return $this->counter; } private function getFromArray($array, $index, $default="") { if (!is_array($array)) return $default; if (isset($array[$index])) return $array[$index]; return $default; } public function getSqlFromArray($eingabe, &$set, &$fields, &$vals) { foreach($eingabe as $feldname=>$inhalt) { $set.=$feldname . "=" . $inhalt . ","; $fields.=$feldname . ","; $vals.=$inhalt . ","; } if (strlen($fields)>2) { $set=substr($set,0,-1); $fields=substr($fields,0,-1); $vals=substr($vals,0,-1); } } } ?> Kontakt zu Pössl Sport- und Freizeit GmbH

Error thrown

Class 'DBAccess' not found