Campustream 1.0
A social network MQP for WPI
core/lib/database.php
Go to the documentation of this file.
00001 <?php
00002         
00003 class Database {
00004         
00005         var $link = null;
00006         
00007         function __construct($name) {
00008                 
00009                 if(!empty($name)) {
00010                 
00011                         require($GLOBALS['APPROOT'] . 'application/config/database.php');
00012                 
00013                         $this->_connect(
00014                                 $config[$name]['host'],
00015                                 $config[$name]['user'],
00016                                 $config[$name]['pass'],
00017                                 $config[$name]['db']
00018                         );
00019                 
00020                 }
00021                 
00022         }
00023         
00024         function _connect($host, $user, $pass, $db) {
00025                 
00026                 $this->link = new mysqli($host,$user,$pass,$db);
00027                 $this->query("SET NAMES 'utf8'");
00028                 
00029         }
00030         
00031         function query($sql) {
00032                 return $this->link->query($sql);
00033         }
00034         
00035         function getInsertID() {
00036                 return $this->link->insert_id;
00037         }
00038         
00039         function escape($string) {
00040                 return $this->link->real_escape_string($string);
00041         }
00042         
00043         function close() {
00044                 $this->link->close();
00045         }
00046 
00047         function error() {
00048                 return $this->link->error;
00049         }
00050         
00051         function errno() {
00052                 return $this->link->errno;
00053         }
00054         
00055         function getObject() {
00056                 return $this->link;
00057         }
00058         
00059 }