PHP Classes

File: output/class.databank.php

Recommend this page to a friend!
  Classes of Martijn Waeyenbergh   PHP MySQL Generator   output/class.databank.php   Download  
File: output/class.databank.php
Role: Sample output
Content type: text/plain
Description: Example databank CLASS
Class: PHP MySQL Generator
Generate classes to access MySQL database tables
Author: By
Last change:
Date: 2 years ago
Size: 798 bytes


Class file image Download
<?php require_once("settings.php"); class databank{ private $connection; public function __construct(){ try { $this->connection = new PDO("mysql:host=".DBSERVER, DBUSER, DBPASSWD.";charset=utf8"); $this->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $this->connection->exec("CREATE DATABASE IF NOT EXISTS `".DB."`;"); return true; }catch (PDOException $e) { return false; } } public function connect(){ $this->connection = new PDO("mysql:host=".DBSERVER.";charset=utf8;dbname=".DB, DBUSER, DBPASSWD); $this->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); return $this->connection; } public function __destruct(){ $this->connection = null; } }