<?php
//connect your database
class Connect extends PDO
{
public function __construct()
{
try
{
//all variables and values i.e $dbuser e.t.c located in this file outside of the web root directory
$db_config = require 'db_config_file';
parent::__construct("mysql:host=$host; dbname=$dbname", $dbuser, $dbpass, array(PDO::MYSQL_ATTR_INIT_COMMAND => $attrinitcmd));
$this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$this->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
}
catch(PDOException $e)
{
die("Imeshindwa kuunganishwa na ifadhi data");
}
}
}
?>