Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- class MySql {
- public function query($sql){
- $query = @mysql_query($sql, $this->handle) or die(mysql_errno().": ".mysql_error());
- return new Result($query);
- }
- public function connect($host, $root, $pass, $data){
- $connect = @mysql_connect($host, $root, $pass) or die(mysql_errno().": ".mysql_error());
- @mysql_select_db($data, $connect) or die(mysql_errno().": ".mysql_error());
- $this->handle = $connect;
- return $connect;
- }
- public function put($str){
- return new Text($str);
- }
- public function last(){
- return @mysql_insert_id($this->handle);
- }
- public function close(){
- return @mysql_close($this->handle);
- }
- }
- class Result extends MySql{
- public function Result($result){
- $this->query = $result;
- }
- public function fetch(){
- return @mysql_fetch_array($this->query);
- }
- public function is(){
- return ($this->query?true:false);
- }
- public function cell($num=0){
- $row = @mysql_fetch_row($this->query);
- return $row[$num];
- }
- public function num(){
- return @mysql_num_rows($this->query);
- }
- public function finish(){
- return $this->query;
- }
- }
- class Text extends MySql{
- public function Text($text){
- $this->text = $text;
- }
- public function hash(){
- return sha1($this->text);
- }
- public function protect(){
- if(get_magic_quotes_runtime()){
- $this->text = htmlspecialchars(stripslashes($this->text));
- }
- return @mysql_real_escape_string($this->text);
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment