Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- *
- * */
- class Mysql_Con {
- // Urceny promenych
- public $debug=1;
- public $db_name;
- public $db_host;
- public $db_user;
- public $db_pass;
- protected $relation;
- protected $result;
- protected $query=array();
- protected $query_indetifier;
- public $debug_var=TRUE; // nastavit na true jestli chcete aby byla result array rovnou vypsana
- //funkce pro nastavení promenych
- function setlogin($name,$host,$pass,$user){
- $this->db_host=$host;
- $this->db_name=$name;
- $this->db_pass=$pass;
- $this->db_user=$user;
- return $this;
- }
- function connect(){
- $this->relation=mysqli_connect($this->db_host, $this->db_user, $this->db_pass, $this->db_name) or die(mysqli_error($this->relation));
- return $this;
- }
- function disconnect(){
- mysqli_close($this->relation) or die(mysqli_error($this->relation));
- return $this;
- }
- }
- class mysql_Query extends Mysql_Con {
- function append($input){
- $this->query[$this->query_indetifier].=" ".$input;
- return $this;
- }
- function setQuery($input){
- if(array_key_exists($input, $this->query)):
- $this->query_indetifier=$input;
- else:
- $this->query[$input]="";
- $this->query_indetifier=$input;
- endif;
- return $this;
- }
- function select(){
- $this->result=mysqli_query($this->relation, $this->query[$this->query_indetifier]) or die(mysqli_error($this->relation));
- return $this;
- }
- /*function insert(){
- }*/
- function result(){
- $this->result=mysqli_fetch_array($this->result) or die(mysqli_error($this->relation));
- if($this->debug_var == TRUE):
- echo '<p style="background-color: gray; color:white">';
- print_r($this->result);
- echo '</p>';
- endif;
- return $this;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement