Next Previous Contents

21. Appendix I phpDB.inc Example

Submitted by: Joe Thong darkjoe@softhome.net Site URL: http://phpdb.linuxbox.com

Description: A PHP database wrapper for various database servers with a powerful Recordset for result data manipulation. Database results are flushed automatically by phpDB.

To get this file, in the web-browser, save this file as 'Text' type as phpDB.inc


<?php
/*
Name: phpDB General module
Version: 1.02bR6
Description: A PHP database wrapper for various 
        database servers.  Database results are flushed 
        automatically by phpDB.  Supported database 
        servers are MySQL, MSQL, PostgreSQL, Microsoft 
        SQL Server and Sybase. 
*/

        if (!defined("_PHPDB_GENERAL_LAYER")) {
          define("_PHPDB_GENERAL_LAYER", 1 );
        }
        else
                return;
        
        // Fill in the database server that you're
        // going to use.  Consult the phpDB Reference
        // Manual for more information
        $databaseType = '';
        // The phpDB module root path.  No trailing slash
        $phpDBRootPath = '.';   
        
        function useDB($dbType = "") 
        {
                GLOBAL $phpDBRootPath;
                switch (strtolower($dbType)) 
                {
                        case "mysql":
                        case "msql":
                        case "postgresql":
                        case "mssql":
                        case "sybase":
                        case "informix":
                                include("$phpDBRootPath". "/phpDB-" . "$dbType.lib");
                                break;
                        case "":
                                die("Please edit phpDB.inc in order to use phpDB");
                                return false;
                        default:
                                die("Invalid database selection");
                                return false;           
                }                                       
                return true;            
        }
        
        useDB($databaseType);
?>


Next Previous Contents