punbb/include/dblayer/common_db.php
changeset 7 98bbc533541c
equal deleted inserted replaced
6:5e1f1e916419 7:98bbc533541c
       
     1 <?php
       
     2 /***********************************************************************
       
     3 
       
     4   Copyright (C) 2002-2008  PunBB.org
       
     5 
       
     6   This file is part of PunBB.
       
     7 
       
     8   PunBB is free software; you can redistribute it and/or modify it
       
     9   under the terms of the GNU General Public License as published
       
    10   by the Free Software Foundation; either version 2 of the License,
       
    11   or (at your option) any later version.
       
    12 
       
    13   PunBB is distributed in the hope that it will be useful, but
       
    14   WITHOUT ANY WARRANTY; without even the implied warranty of
       
    15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    16   GNU General Public License for more details.
       
    17 
       
    18   You should have received a copy of the GNU General Public License
       
    19   along with this program; if not, write to the Free Software
       
    20   Foundation, Inc., 59 Temple Place, Suite 330, Boston,
       
    21   MA  02111-1307  USA
       
    22 
       
    23 ************************************************************************/
       
    24 
       
    25 
       
    26 // Make sure no one attempts to run this script "directly"
       
    27 if (!defined('PUN'))
       
    28 	exit;
       
    29 
       
    30 // import Enano data
       
    31 global $dbdriver;
       
    32 $db_type =& $dbdriver;
       
    33 
       
    34 //
       
    35 // Return current timestamp (with microseconds) as a float (used in dblayer)
       
    36 //
       
    37 if (defined('PUN_SHOW_QUERIES'))
       
    38 {
       
    39 	function get_microtime()
       
    40 	{
       
    41 		list($usec, $sec) = explode(' ', microtime());
       
    42 		return ((float)$usec + (float)$sec);
       
    43 	}
       
    44 }
       
    45 
       
    46 
       
    47 // Load the appropriate DB layer class
       
    48 switch ($db_type)
       
    49 {
       
    50 	case 'mysql':
       
    51 		require PUN_ROOT.'include/dblayer/enano_mysql.php';
       
    52 		break;
       
    53 
       
    54 	case 'pgsql':
       
    55 		require PUN_ROOT.'include/dblayer/enano_pgsql.php';
       
    56 		break;
       
    57 
       
    58 	default:
       
    59 		error('\''.$db_type.'\' is not a valid database type. Please check settings in config.php.', __FILE__, __LINE__);
       
    60 		break;
       
    61 }
       
    62 
       
    63 // Create the database adapter object (and open/connect to/select db)
       
    64 $pun_db = new DBLayer();