phpOpenTracker/phpOpenTracker/Database Factory.php,NONE,1.1

Sebastian Bergmann <[email protected]> Mon, 01 Mar 2004 08:57:00 +0000
Newsgroups gmane.comp.web.phpopentracker.cvs
Message-ID <[email protected]>
Update of /cvsroot/phpopencounter/phpOpenTracker/phpOpenTracker/Database
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20336/phpOpenTracker/Database

Added Files:
	Factory.php 
Log Message:
Flush.

--- NEW FILE: Factory.php ---
<?php
//
// phpOpenTracker - The Website Traffic and Visitor Analysis Solution
//
// Copyright 2000 - 2004 Sebastian Bergmann. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// $Id: Factory.php,v 1.1 2004/03/01 08:56:58 bergmann Exp $
//

require_once POT_INCLUDE_PATH . 'Database/Exception.php';
require_once POT_INCLUDE_PATH . 'Configuration.php';

class phpOpenTracker_Database_Factory {
    private static $instance = null;

    private function __construct() {
    }

    public static function getInstance() {
        if (self::$instance == null) {
            $configuration = phpOpenTracker_Configuration::getConfiguration();
            $class         = 'phpOpenTracker_Database_Driver_' . $configuration['db_type'];

            @include_once POT_INCLUDE_PATH . 'Database/Driver/' . $configuration['db_type'] . '.php';

            if (class_exists($class)) {
                self::$instance = new $class;
            } else {
                throw new phpOpenTracker_Database_Exception(
                  sprintf(
                    'Could not load "%s" database driver.',

                    $configuration['db_type']
                  )
                );
            }
        }

        return self::$instance;
    }
}

//
// "phpOpenTracker essenya, gul meletya;
//  Sebastian carneron PHP."
//
?>



-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click