PHP Classes

File: system.inc

Recommend this page to a friend!
  Classes of Kevin Cadman   Data Workings   system.inc   Download  
File: system.inc
Role: Configuration script
Content type: text/plain
Description: System Configuration and Database Connection
Class: Data Workings
Access database table records as objects
Author: By
Last change:
Date: 18 years ago
Size: 876 bytes
 

Contents

Class file image Download
<?php
//You may want to change ini_set to the path of your PEAR installation.
//ini_set("include_path",ini_get("include_path").":/var/www/html/PEAR/");

//SET CONFIGURATIONS ACCORDINGLY

$_conf["db_username"] = "root";
$_conf["db_password"] = "";
$_conf["db_host"] = "localhost";
$_conf["db_name"] = "my_table";
$_conf["db_type"] = "mysql";

//Include required files
require_once 'DB.php';
require_once
'dataclass.inc';

//Set up DB connection
$dsn = $_conf["db_type"]."://".$_conf["db_username"].":".$_conf["db_password"]."@".$_conf["db_host"]."/".$_conf["db_name"];
$options = array(
   
'debug' => 2,
   
'portability' => DB_PORTABILITY_ALL,
);

$db =& DB::connect($dsn, $options);
if (
PEAR::isError($db)) {
    die(
$db->getMessage());
}

//IMPORTANT! PEAR DB's fetchmode MUST BE SET TO OBJECT!
$db->setFetchMode(DB_FETCHMODE_OBJECT);
?>