summaryrefslogtreecommitdiffstats
path: root/App/database/dbSetup.php
blob: 30bbe42fee39c689fb9f5c466df1dc84a4ed03b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
/**
 * Created by PhpStorm.
 * User: brolaugh
 * Date: 2/13/16
 * Time: 4:00 AM
 */

namespace App\database;


class dbSetup
{
    private $db;
    private $server = "home.rickfo.se";
    private $username = "brolaugh";
    private $password = "rickardh";
    private $database = "brolaugh_tasklist";


    /**
     * dbSetup constructor.
     */
    public function __construct(){
        $this->db = new \Mysqli($this->server, $this->username, $this->password, $this->database);
        if(!$this->db->set_charset("utf8")) {
            printf("Error loading character set utf8: %s\n", $this->db->error);
            exit();
        }
    }
    public function __destruct() {
      $this->db->close();
   }
    /**
     * @return Mysqli
     */
    protected function getDb()
    {
        return $this->db;
    }
    protected function makeValuesReferenced(&$arr)
      {
          $refs = array();
          foreach($arr as $key => $value)
              $refs[$key] = &$arr[$key];
          return $refs;
      }
}