summaryrefslogtreecommitdiff
path: root/db.class.php
diff options
context:
space:
mode:
authorChristian Pointner <equinox@ffgraz.net>2008-12-06 07:23:29 +0000
committerChristian Pointner <equinox@ffgraz.net>2008-12-06 07:23:29 +0000
commit61448e4c2aabaf06cdae4160de77aaac8c7ad692 (patch)
tree52cf75f52eb999b9677af33c42556d1deec41372 /db.class.php
parent9cee05c341490e0329311a16c0d54a8c27ec5143 (diff)
added data.php
Diffstat (limited to 'db.class.php')
-rw-r--r--db.class.php61
1 files changed, 61 insertions, 0 deletions
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 @@
+<?php
+/*
+ * Copyright (C) 2006 Gaubatz Patrick <patrick@gaubatz.at>
+ *
+ * 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);
+ }
+}
+?>