From 61448e4c2aabaf06cdae4160de77aaac8c7ad692 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sat, 6 Dec 2008 07:23:29 +0000 Subject: added data.php --- db.class.php | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 db.class.php (limited to 'db.class.php') diff --git a/db.class.php b/db.class.php new file mode 100644 index 0000000..6603804 --- /dev/null +++ b/db.class.php @@ -0,0 +1,61 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +class DB { + var $user, $pass, $host, $dbname; + var $db; + var $res; + + function DB($user, $pass, $host, $dbname) { + $this->user = $user; + $this->pass = $pass; + $this->host = $host; + $this->dbname = $dbname; + + $this->connect(); + } + + function connect() { + $this->db = mysql_connect($this->host, $this->user, $this->pass) + or $this->error("Verbindungsaufbau fehlgeschlagen"); + + mysql_select_db($this->dbname); + } + + function error($msg) { + die($msg . ": " . @mysql_error()); + } + + function query($query) { + $this->res = mysql_query($query, $this->db) + or $this->error("Fehler bei Datenbankanfrage"); + } + + function numObjects() { + return mysql_num_rows($this->res); + } + + function getNextObject() { + if (!$this->res) { + return; + } + return mysql_fetch_object($this->res); + } +} +?> -- cgit v1.2.1