Guest User

Untitled

a guest
Aug 31st, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. class DB
  5. {
  6. public $host;
  7. public $user;
  8. public $pass;
  9. public $database;
  10. public $db;
  11. function __construct($host,$user,$pass,$database)
  12. {
  13.  
  14. $this->host=$host;
  15. $this->user=$user;
  16. $this->pass=$pass;
  17. $this->database=$database;
  18.  
  19. $this->db=@mysql_connect($this->host,$this->user,$this->pass) or die(mysql_error());
  20. mysql_select_db($this->database) or die(mysql_error());
  21. }
  22.  
  23.  
  24. function select($from,$where)
  25. {
  26.  
  27. $query="select * from ". $from ." where ". $where;
  28. $result=$this->query($query);
  29. return $result;
  30.  
  31. }
  32. function insert($into,$values)
  33. {
  34.  
  35. $query="INSERT INTO ". $into ." VALUES( ". $values . ")";
  36. if($this->query($query))
  37. {
  38. return true;
  39. }
  40. else
  41. {
  42. return false;
  43. }
  44. }
  45.  
  46. function delete($from,$where)
  47. {
  48.  
  49. $query="DELETE FROM ". $from ." WHERE ". $where;
  50. if($this->query($query))
  51. return true;
  52. else
  53. return false;
  54. }
  55. function display($result)
  56. {
  57.  
  58. while($inform=$inform=$this->fetch_array($result))
  59. {
  60. echo $inform['film_ad']."<br />";
  61. }
  62. }
  63. function query($query)
  64. {
  65. return mysql_query($query);
  66. }
  67. function fetch_array($result)
  68. {
  69. return mysql_fetch_array($result);
  70.  
  71. }}
  72.  
  73. $test=new DB('localhost','root','','cinema');
  74. $result=$test->select("filmler","film_id<5");
  75. $test->display($result);
  76.  
  77. ?>
Add Comment
Please, Sign In to add comment