Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Created by PhpStorm.
- * User: asus
- * Date: 2/10/14
- * Time: 7:22 PM
- */
- namespace core\classes;
- class db{
- private $db_host,$db_name,$db_login,$db_pass;
- protected $result,$select,$where,$connect;
- public function connect(){
- $this->connect=mysqli_connect($this->db_host,$this->db_login,$this->db_pass,$this->db_name);
- }
- protected function setSelect($select){
- $this->select=$select;
- }
- public function setWhere($where){
- $this->where=$where;
- }
- public function select($tableName){
- $coma='`';
- $table=$tableName;
- if($this->where!=false){
- $flag=true;
- }
- switch($flag):
- case true:
- $query="SELECT ".$coma.$this->select.$coma." FROM ".$coma.$this->db_name.$coma.".".$table.$coma." WHERE ".$this->where.";";
- break;
- case false:
- $query="SELECT ".$coma.$this->select.$coma." FROM ".$coma.$this->db_name.$coma.".".$coma.$table.$coma.";";
- break;
- endswitch;
- $result=mysqli_query($this->connect,$query);
- return $result;
- }
- public function __construct(){
- $this->db_host="localhost";
- $this->db_name="*****";
- $this->db_login="*****";
- $this->db_pass="*********";
- $this->result=false;
- $this->select=false;
- $this->where=false;
- $this->connect=false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement