Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class DB{
- public $hostname,$database,$username,$password;
- public function __construct(){
- $this->hostname = "";
- $this->database = "";
- $this->username = "";
- $this->password = "";
- $this->errors = array();
- }
- private function connessione(){
- mysql_connect($this->hostname,$this->username,$this->password) or $this->errors[] = mysql_error();
- mysql_select_db($this->database) or $this->errors[] = mysql_error();
- $this->PrintErrors();
- }
- public function query($query){
- $this->query = $query;
- $this->result = mysql_query($this->query) or $this->errors[] = mysql_error();
- if($this->result){
- return $this->result;
- }else{
- $this->PrintErrors();
- }
- }
- public function PrintErrors(){
- foreach(array_unique($this->errors) as $key=>$value){
- if(!empty($value)){
- echo "Errore : ".$value."<br/>";
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement