* * 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); } } ?>