Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class PDO_Database_Connection{
- private $host="account.mysqlhost.com";
- private $database="mydatabase";
- private $user="myusername";
- private $password="my.1.Password";
- public $dbh;
- public $error;
- public $status;
- public function __construct(/* $args */){
- /*
- foreach( $args as $key => $value ){
- $this->$key = $value;
- }
- */
- try {
- $this->dbh = new PDO("mysql:host=foerster.yourwebhostingmysql.com;dbname=$this->database", $this->user, $this->password);
- /*** echo a message saying we have connected ***/
- //echo 'Connected to database';
- $this->status = "connected";
- }
- catch(PDOException $e)
- {
- //echo $e->getMessage();
- $this->error = $e->getMessage();
- }
- }
- }
- /*
- $db = new PDO_Database_Connection();
- $dbh = $db->dbh;
- echo $db->status;
- echo $db->error;
- */
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement