PX : code

database class by teschda
Download this code


<?
// =============================================
// datenbank verbindungen
// =============================================
// autor: christian leh
// date: 17.12.2000
// =============================================
// typen:
//      1: mysql

class database {
        // benötige variablen
        var HOST = \\\"\\\";
        var USER = \\\"\\\";
        var PASSWORD = \\\"\\\";
        var TYPE = \\\"\\\";
        var CID = \\\"\\\";

        // verbindung herstellen
        function init ($type) {
                $this->TYPE = $type;
                switch ($type) {
                        // mysql
                        case 1:
                                $cid = mysql_pconnect($this->HOST, $this->USER, $this->PASSWORD);
                                if (!$cid) return false;
                                $this->CID = $cid;
                                if (!mysql_select_db($this->DATABASE)) return false;
                                return true;
                        // unbekannt
                        default:
                                return false;
                }
        }

        // query ausführen
        function query ($query) {
                if (empty($query)) return false;
                if (!$this->CID) init($this->TYPE);
                switch ($type) {
                        // mysql
                        case 1:
                                $result = mysql_query($query);
                                if (!result) return false;
                                return $result;
                        // unbekannt
                        default:
                                return false;
                }
        }

        // daten holen
        function fetch ($result) {
                if (empty($result)) return false;
                $data = mysql_fetch_array($result);
                if (!is_array($data)) return false;
                return $data;
        }
}
?>

Comments or questions?
PX is running PHP 5.2.17
Thanks to Miranda Productions for hosting and bandwidth.
Use of any code from PX is at your own risk.