File: fwphp/01mater/shop/model/database.php

Recommend this page to a friend!
  Classes of Slavko Srakocic  >  B12 PHP FW  >  fwphp/01mater/shop/model/database.php  >  Download  
File: fwphp/01mater/shop/model/database.php
Role: Example script
Content type: text/plain
Description: Example script
Class: B12 PHP FW
Manage database records with a PDO CRUD interface
Author: By
Last change: ver 7.0.5 mnu, msg, mkd FUNCTIONAL namespaces, CRUD PDO trait, pretty URL-s
Date: 1 month ago
Size: 843 bytes
 

Contents

Class file image Download
<?php
// J:\awww\www\fwphp\glomodul\z_examples\02_mvc\guitar_shop\model\database.php
// Set up the database connection

// my h ome develop. PC :
$dsn = 'mysql:host=localhost;dbname=z_shop'; //my_guitar_shop2
$username = 'mgs_user'; //shop_user mgs_user 'root' ; //
$password = 'pa55word'; //pa55word '' ; //

/*
// eu5 free hosting : not localhost
$dsn = 'mysql:host=fdb21.freehostingeu.com;dbname=3266814_cms';
$username = '3266814_cms'; //mgs_user
$password = 'MYLONGER_SIMPLE'; //pa55word
*/

$options = array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION);

try {
   
$db = new PDO($dsn, $username, $password, $options);
                       
//echo '<pre>'.'$db='; print_r($db); echo '</pre>';
} catch (PDOException $e) {
   
$error_message = $e->getMessage();
    include(
'errors/db_error_connect.php');
    exit();
}

For more information send a message to info at phpclasses dot org.