Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class DbAction{
- public $query;
- public $result;
- public $connection;
- public $num_rows;
- public $row;
- private $host;
- private $db_user;
- private $db_password;
- private $db_name;
- /*
- CONSTRUCTOR
- */
- public function __construct(){
- $this->connection;
- $this->query = '';
- $this->result = '';
- $this->num_rows = '';
- $this->row = '';
- $this->host = "localhost";
- $this->db_user = "root";
- $this->db_password = "";
- $this->db_name = "osadnicy";
- }
- /*
- STARTS CONNECTION
- */
- public function connection(){
- $this->connection = new mysqli($this->host, $this->db_user, $this->db_password, $this->db_name );
- if($this->connection == true){
- return true;
- } else {
- $this->errorRaport();
- return false;
- }
- }
- /*
- RETURNS RESULT
- */
- public function getResult($query){
- if ($this->result = $this->connection->query($query)) {
- return $this->result;
- } else {
- return false;
- }
- }
- /*
- RETURNS NUMBER OF ROW
- */
- public function rowNumber(){
- if($this->numRows = $this->result->num_rows){
- return $this->numRows;
- } else {
- return false;
- }
- }
- /*
- RETURNS ROW
- */
- public function row(){
- if($this->row = $this->result->fetch_assoc()){
- return $this->row;
- } else {
- return false;
- }
- }
- } // END OF CLASS DbAction
- $db = new DbAction();
- $db->connection();
- $db->getResult("SELECT * FROM `uzytkownicy`");
- echo $db->rowNumber();
- $row = $db->row();
- echo $row['user'];
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement