Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class DbDriver {
- private $host;
- private $user;
- private $password;
- private $database;
- private $last_query;
- private $handle;
- function __construct($host,$user,$password,$database){
- $this->host = $host;
- $this->user = $user;
- $this->password = $password;
- $this->database = $database;
- $this->connect();
- }
- private function connect() {
- $this->handle = @new mysqli($this->host,$this->user,$this->password,$this->database);
- $this->handle->query("SET NAMES 'utf8' ");
- if ($this->handle->connect_errno){
- echo "Błąd połączenia z bazą";
- }
- }
- function getSalon($id){
- $query = "SELECT * FROM `adminpanel_salon` WHERE `id`='{$id}' ";
- $this->last_query = $this->handle->query($query);
- while ($row = $this->last_query->fetch_object()) {
- $data = array(
- "id" => $row->id,
- "name" => $row->name
- );
- }
- return $data['name'];
- }
- function getUsersDataAsTable($access){
- $query = "SELECT * FROM `adminpanel_users` WHERE `access`='{$access}'";
- $this->last_query = $this->handle->query($query);
- ?>
- <table class="table">
- <thead>
- <tr>
- <th>#</th>
- <th>User</th>
- <th>Uprawnienia</th>
- <th>Pracownik</th>
- <th>Salon</th>
- </tr>
- </thead>
- <tbody>
- <?php
- while ($row = $this->last_query->fetch_object()) {
- echo "<tr>";
- echo '<td>'. $row->id.'</td>';
- echo '<td>'. $row->user.'</td>';
- echo '<td>'. $row->access.'</td>';
- echo '<td>'. $row->parent.'</td>';
- echo '<td>'. $this->getSalon($row->salon).'</td>';
- echo "</tr>";
- }
- ?>
- </tbody>
- </table>
- <?php
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement