PHP Classes

File: includes/database.php

Recommend this page to a friend!
  Classes of Mark Richards   CliqonV4   includes/database.php   Download  
File: includes/database.php
Role: Example script
Content type: text/plain
Description: Example script
Class: CliqonV4
Framework with modules to build Web applications
Author: By
Last change:
Date: 6 years ago
Size: 981 bytes
 

Contents

Class file image Download
<?php
/**
Database handling
; type = 'mysql'
; server = 'localhost'
; dbname = ''
; username = ''
; password = ''
; port = '3306'
; charset = 'utf8'
*/
try {
    global
$cfg;
   
$dbcfg = $cfg['database'];
   
// This gets the DB Handler loaded
   
loadFile('framework/core/Rb.php');
    switch(
$dbcfg['type']){
       
        case
"mysql":
        case
"pgsql":
           
R::setup($dbcfg['type'].':host='.$dbcfg['server'].';dbname='.$dbcfg['dbname'],$dbcfg['username'],$dbcfg['password']);
           
R::useWriterCache(true);
        break;

        case
"sqlite":
           
R::setup('sqlite:'.$basedir.$dbcfg['file']);
        break;

        case
"firebird":
           
$dsn = ['firebird:host='.$dbcfg['server'].';dbname='.$dbcfg['dbname'],$dbcfg['username'],$dbcfg['password']];
           
$clq->set('dsn', $dsn);
        break;
        case
"odbc":
           
$dsn = 'odbc:'.$dbcfg['dbname'];
           
$clq->set('dsn', $dsn);
        break;
    }

} catch (
Exception $e) {
   
Debugger::log('PDO Error: '.$e->getMessage());
};