Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class DB
- {
- public $host;
- public $user;
- public $pass;
- public $database;
- public $db;
- function __construct($host,$user,$pass,$database)
- {
- $this->host=$host;
- $this->user=$user;
- $this->pass=$pass;
- $this->database=$database;
- $this->db=@mysql_connect($this->host,$this->user,$this->pass) or die(mysql_error());
- mysql_select_db($this->database) or die(mysql_error());
- }
- function select($from,$where)
- {
- $query="select * from ". $from ." where ". $where;
- $result=$this->query($query);
- return $result;
- }
- function insert($into,$values)
- {
- $query="INSERT INTO ". $into ." VALUES( ". $values . ")";
- if($this->query($query))
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- function delete($from,$where)
- {
- $query="DELETE FROM ". $from ." WHERE ". $where;
- if($this->query($query))
- return true;
- else
- return false;
- }
- function display($result)
- {
- while($inform=$inform=$this->fetch_array($result))
- {
- echo $inform['film_ad']."<br />";
- }
- }
- function query($query)
- {
- return mysql_query($query);
- }
- function fetch_array($result)
- {
- return mysql_fetch_array($result);
- }}
- $test=new DB('localhost','root','','cinema');
- $result=$test->select("filmler","film_id<5");
- $test->display($result);
- ?>
Add Comment
Please, Sign In to add comment