Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Class name : Database Class G
- * @Author: Muhanned Mohammed Salim Al-Risi
- * @Mail : kaka9909@hotmail.com
- * @country:Sultanat of Oman
- * @param: this class is V1 and its free for use but don't change the copyright :)
- */
- class db{
- private $db=array();
- // connect function
- public function connect($local,$user,$pass,$dbname){
- $this->db['localhost']=!empty($local)?$local:false;
- $this->db['username']=!empty($user)?$user:false;
- $this->db['password']=!empty($pass)?$pass:false;
- $this->db['dbname']=!empty($dbname)?$dbname:false;
- $this->db['connect']=mysql_connect($this->db['localhost'],$this->db['username'],$this->db['password']) or die("Database Error ".mysql_error());
- $this->db['select']=mysql_select_db($this->db['dbname']) or die(mysql_error());
- }
- // close function
- public function close(){
- mysql_close($this->db['connect']);
- }
- //query @var
- public $sql=array();
- #query function
- public function query($sql){
- $this->sql['query']=!empty($sql)?$sql:die("Empty source ");
- $this->sql['querys']= mysql_query($this->sql['query']) or die(mysql_error());
- return $this->sql['querys'];
- }
- public function fetch($query){
- $this->sql['fetch']=mysql_fetch_assoc($query) or die(mysql_error());
- return $this->sql['fetch'];
- }
- }
- ?>
Add Comment
Please, Sign In to add comment