Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ##########################
- # ->Error_report and query class
- # ->By Paulo Serra
- # ->V. 1.0
- ##########################
- require_once('exceptions.php');
- class error_report extends debuger{
- //insert here your db connection
- var $username = '';
- var $localhost = '';
- var $pass = '';
- var $db ='';
- function __construct(){}
- //Not been used in this version
- public function __set($data, $value) {
- $this->data[$data] = $value;
- }
- //Not been used in this version
- public function __get($data) {
- return $this->data[$data];
- }
- //Make the connection
- private function db_connect(){
- if(!$coneccao = mysql_connect($this->localhost, $this->username, $this->pass)){
- $this -> error_handling(mysql_error(), 0);
- }
- if(!$bd = mysql_select_db($this->db)){
- $this -> error_handling(mysql_error(), 0);
- }
- return $coneccao;
- }
- //make the query
- public function query($query){
- $this->db_connect();
- if(!$sql = mysql_query($query)){
- $this -> error_handling(mysql_error(), $query);
- }
- return $sql;
- }
- //Get the number of rows
- public function db_num_rows($sql){
- if(!$rows = mysql_num_rows($sql)){
- $this -> error_handling(mysql_error(), $sql);
- }else{
- return $rows;
- }
- }
- //Get the fields Name
- public function db_fields($sql){
- if(!$campos = mysql_fetch_field($sql)){
- $this -> error_handling(mysql_error(), $sql);
- }else{
- for($i=0; $i < mysql_num_fields($sql); $i++){
- $fields[$i] = mysql_field_name($sql, $i);
- }
- return $fields;
- }
- }
- //Get the data fromm DB
- public function db_data($sql){
- while($data = mysql_fetch_array($sql)){
- $resultado[] = $data;
- }
- return $resultado;
- }
- }
- ?>
Add Comment
Please, Sign In to add comment