dbc = mysql_connect($host, $user, $pass)) { $error = 'Cannot connect to MySQL server. In file '.$file.' in line '.$line.'. Date: '.date('Y-m-d H:i:s').'
'.CRLF; $this->bConnect= false; //die($error); return false; }else $this->bConnect= true; }else{ if(!$this->dbc = mysql_connect($host, $user)) { $error = 'Cannot connect to MySQL server. In file '.$file.' in line '.$line.'. Date: '.date('Y-m-d H:i:s').'
'.CRLF; //die($error); //FIXME: return? die? $this->bConnect= false; }else $this->bConnect= true; } if(!@mysql_query("USE ".$base, $this->dbc)) { $error = 'Error '.mysql_error($this->dbc).' in query '.$query.'. In file '.$file.' in line '.$line.'. Date: '.date('Y-m-d H:i:s').'
'.CRLF; $this->bConnect= false; //die($error); }else $this->bConnect= true; $this->showError = true; return } function query($query, $file = '', $line = 0) { if(!$result = @mysql_query($query, $this->dbc)) { $error = 'Error '.mysql_error($this->dbc).' in query '.$query.'. In file '.$file.' in line '.$line.'. Date: '.date('Y-m-d H:i:s').'
'.CRLF; if($this->showError) { echo $error; $this->bQueryrun = false; } } else $this->bQueryrun = true; return new dbcResult($result); } function query_bool($query, $file = '', $line = 0) { if(!$result = @mysql_query($query, $this->dbc)) { $error = 'Error '.mysql_error($this->dbc).' in query '.$query.'. In file '.$file.' in line '.$line.'. Date: '.date('Y-m-d H:i:s').'
'.CRLF; if($this->showError) { echo $error; } } return ($result?true:false); } function insert_id() { $id = $this->firstCell("SELECT LAST_INSERT_ID() as id"); return $id; } function fetch_array($query, $type = SQL_BOTH) { $result = $this->query($query); return $result->fetch_array($type); } function first_cell($query) { $result = $this->query($query); $row = $result->fetch_array(SQL_NUM); return $row[0]; } function change_base($base, $file = '', $line = 0) { if(!$result = @mysql_query('USE '.$base, $this->dbc)) { $error = 'Error '.mysql_error($this->dbc).' in query '.$query.'. In file '.$file.' in line '.$line.'. Date: '.date('Y-m-d H:i:s').'
'.CRLF; if($this->showError) { echo $error; } } return ($result?true:false); } function close() { @mysql_close($this->dbc); unset($this); } } class dbcResult { function dbcResult($result) { $this->result = $result; } function fetch_array($type = SQL_BOTH) { return @mysql_fetch_array($this->result, $type); } function first_cell() { $row = @mysql_fetch_row($this->result); return $row[0]; } function num_rows() { return @mysql_num_rows($this->result); } } ?>