exported from svn
This commit is contained in:
commit
03995d3bc6
85 changed files with 14765 additions and 0 deletions
71
scripts/database.class.php
Normal file
71
scripts/database.class.php
Normal file
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
// call database class
|
||||
class Query {
|
||||
// Variablen
|
||||
var $_sql = "";
|
||||
var $_result = 0;
|
||||
var $_errno = 0;
|
||||
var $_error = "";
|
||||
|
||||
//Konstruktor
|
||||
function Query($sql)
|
||||
{
|
||||
// Query in der Klasse speichern
|
||||
$this->_sql = trim($sql);
|
||||
$this->_result = mysql_query($this->_sql);
|
||||
if(!$this->_result) {
|
||||
$this->_errno = mysql_errno();
|
||||
$this->_error = mysql_error();
|
||||
}
|
||||
}
|
||||
|
||||
//Methoden
|
||||
function error()
|
||||
{
|
||||
// Result-ID in einer tmp-Variablen speichern
|
||||
$tmp = $this->_result;
|
||||
// Variable in boolean umwandeln
|
||||
$tmp = (bool)$tmp;
|
||||
// Variable invertieren
|
||||
$tmp = !$tmp;
|
||||
// und zurückgeben
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
function getError() {
|
||||
if($this->error()) {
|
||||
$str = "request:\n".$this->_sql."\n";
|
||||
$str .= "response:\n".$this->_error."\n";
|
||||
$str .= "Errorcode: ".$this->_errno;
|
||||
}
|
||||
else $str = "No error.";
|
||||
return $str;
|
||||
}
|
||||
function getErrno() {
|
||||
return $this->_errno;
|
||||
}
|
||||
|
||||
function fetch() {
|
||||
if($this->error()) {
|
||||
echo "An Error has occurred, please check your MySQL-Query.";
|
||||
$return = null;
|
||||
}
|
||||
else $return = mysql_fetch_assoc($this->_result);
|
||||
return $return;
|
||||
}
|
||||
|
||||
function numRows() {
|
||||
if($this->error()) {
|
||||
$return = -1;
|
||||
}
|
||||
else $return = mysql_num_rows($this->_result);
|
||||
return $return;
|
||||
}
|
||||
|
||||
function free() {
|
||||
// Speicher freimachen
|
||||
mysql_free_result($this->_result);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue