PHP Classes

File: config.php

Recommend this page to a friend!
  Classes of Assontia Patient   PDO Database class   config.php   Download  
File: config.php
Role: Configuration script
Content type: text/plain
Description: Configure your database parameters
Class: PDO Database class
Access SQL databases using PDO
Author: By
Last change:
Date: 12 years ago
Size: 1,347 bytes
 

Contents

Class file image Download
<?php
// PREFERABLE TO PUT THIS FILE AT THE ROOT OF YOUR WEB FOLDER
// SERVER CONFIGURATIONS
class Config {
    protected
$user = 'root'; //
   
protected $pass = ''; // DATABASE USER PASSWORD
   
protected $dbtype = 'mysql'; // DATABASE TYPE
   
protected $host = 'localhost'; // DATABASE HOST
   
protected $dbname = 'pagify'; // DATABASE NAME
   
protected $port = 3306; //To change if your database listen to a different port
   
protected $basepath; // The base path of you application ---> will be use to include file easily later!!!
   
public $class_folder = 'classes'; //Folder name where you store your classes
   
public $library_folder = 'library'; //Folder name where you store your global functions and variables
   
   
protected $dsn = "";
   
   
// Construtor
   
public function __construct() {
       
//@session_start();
       
$this->basepath = $this->get_path('.');
        include_once
$this->basepath . DIRECTORY_SEPARATOR . $this->library_folder . DIRECTORY_SEPARATOR . 'library.php';
       
$this->dsn = $this->buildDsn();
    }
   
   
// Build the string of the DSN
   
private function buildDsn() {
        return
"mysql:host=$this->host;port=$this->port;dbname=$this->dbname";
    }
   
   
// Get the absolute path to your application
   
public function get_path($path) {
        return
realpath($path);
    }
   
   
// Destructor
   
public function __destruct() {
       
    }

}
?>