@@ -1,26 +1,26 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | - //define namespace |
|
4 | - namespace BPT\Database; |
|
3 | + //define namespace |
|
4 | + namespace BPT\Database; |
|
5 | 5 | |
6 | - //use class |
|
7 | - use BPT\Database\Database; |
|
6 | + //use class |
|
7 | + use BPT\Database\Database; |
|
8 | 8 | |
9 | - /** |
|
10 | - * |
|
11 | - */ |
|
12 | - class Handller extends Database |
|
13 | - { |
|
9 | + /** |
|
10 | + * |
|
11 | + */ |
|
12 | + class Handller extends Database |
|
13 | + { |
|
14 | 14 | |
15 | - /** |
|
16 | - * |
|
17 | - */ |
|
18 | - public function __construct(array $settings) |
|
19 | - { |
|
15 | + /** |
|
16 | + * |
|
17 | + */ |
|
18 | + public function __construct(array $settings) |
|
19 | + { |
|
20 | 20 | if(in_array($settings['type'],self::TYPES)){ |
21 | - if($settings['type'] === 'Mysqli'){ |
|
22 | - if(self::CheckParam($settings)){ |
|
23 | - $db = new Mysqlidb([ |
|
21 | + if($settings['type'] === 'Mysqli'){ |
|
22 | + if(self::CheckParam($settings)){ |
|
23 | + $db = new Mysqlidb([ |
|
24 | 24 | 'host' => $this->host, |
25 | 25 | 'username' => $this->username, |
26 | 26 | 'password' => $this->password, |
@@ -28,36 +28,36 @@ discard block |
||
28 | 28 | 'charset' => $this->charset |
29 | 29 | ]); |
30 | 30 | if($db){ |
31 | - $this->connect = $db; |
|
32 | - } else { |
|
33 | - throw new \exception('a problem to connecting'); |
|
34 | - } |
|
35 | - } else { |
|
36 | - throw new \exception('required parameters not found'); |
|
37 | - } |
|
38 | - } |
|
39 | - if($settings['type'] === 'Json' and isset($settings['dbname'])){ |
|
31 | + $this->connect = $db; |
|
32 | + } else { |
|
33 | + throw new \exception('a problem to connecting'); |
|
34 | + } |
|
35 | + } else { |
|
36 | + throw new \exception('required parameters not found'); |
|
37 | + } |
|
38 | + } |
|
39 | + if($settings['type'] === 'Json' and isset($settings['dbname'])){ |
|
40 | 40 | $this->type = $settings['type']; |
41 | 41 | $this->dbname = $settings['dbname']; |
42 | 42 | parent::Json_init(); |
43 | - } else { |
|
43 | + } else { |
|
44 | 44 | throw new \exception('parameter dbanme not found'); |
45 | - } |
|
46 | - } else { |
|
47 | - throw new \exception('parameter type not found'); |
|
48 | - } |
|
49 | - } |
|
45 | + } |
|
46 | + } else { |
|
47 | + throw new \exception('parameter type not found'); |
|
48 | + } |
|
49 | + } |
|
50 | 50 | |
51 | - private static function CheckParam(array $array){ |
|
52 | - if(isset($array['username']) && isset($array['dbname']) && isset($array['password'])){ |
|
51 | + private static function CheckParam(array $array){ |
|
52 | + if(isset($array['username']) && isset($array['dbname']) && isset($array['password'])){ |
|
53 | 53 | $this->host = $array['host'] ?? 'localhost'; |
54 | 54 | $this->username = $array['username']; |
55 | 55 | $this->dbname = $array['dbname']; |
56 | 56 | $this->password = $array['password']; |
57 | 57 | $this->charset = $array['charset'] ?? 'utf8mb4'; |
58 | - return true; |
|
59 | - } else { |
|
60 | - return false; |
|
61 | - } |
|
62 | - } |
|
63 | - } |
|
64 | 58 | \ No newline at end of file |
59 | + return true; |
|
60 | + } else { |
|
61 | + return false; |
|
62 | + } |
|
63 | + } |
|
64 | + } |
|
65 | 65 | \ No newline at end of file |
@@ -1,28 +1,28 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | - //define namespace |
|
4 | - namespace BPT; |
|
3 | + //define namespace |
|
4 | + namespace BPT; |
|
5 | 5 | |
6 | - //use classes |
|
7 | - use Medoo\Medoo; |
|
8 | - use BPT\jsondb |
|
6 | + //use classes |
|
7 | + use Medoo\Medoo; |
|
8 | + use BPT\jsondb |
|
9 | 9 | |
10 | 10 | |
11 | - /** |
|
12 | - * @class Database |
|
13 | - */ |
|
14 | - class Database |
|
15 | - { |
|
11 | + /** |
|
12 | + * @class Database |
|
13 | + */ |
|
14 | + class Database |
|
15 | + { |
|
16 | 16 | |
17 | - /** |
|
18 | - * @const types database |
|
19 | - */ |
|
20 | - const TYPES = array('Mysqli','Medoo','Json'); |
|
17 | + /** |
|
18 | + * @const types database |
|
19 | + */ |
|
20 | + const TYPES = array('Mysqli','Medoo','Json'); |
|
21 | 21 | |
22 | - /** |
|
23 | - * @const Medoo database types |
|
24 | - */ |
|
25 | - const Medoo_Types = array('mysql','mariadb','pgsql','sybase','oracle','mssql', 'sqlite'); |
|
22 | + /** |
|
23 | + * @const Medoo database types |
|
24 | + */ |
|
25 | + const Medoo_Types = array('mysql','mariadb','pgsql','sybase','oracle','mssql', 'sqlite'); |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * @var type database |
@@ -36,40 +36,40 @@ discard block |
||
36 | 36 | protected $host; |
37 | 37 | |
38 | 38 | /** |
39 | - * @var username database username |
|
40 | - */ |
|
39 | + * @var username database username |
|
40 | + */ |
|
41 | 41 | protected $username; |
42 | 42 | |
43 | 43 | /** |
44 | - * @var dbname database name |
|
45 | - */ |
|
44 | + * @var dbname database name |
|
45 | + */ |
|
46 | 46 | protected $dbname; |
47 | 47 | |
48 | 48 | /** |
49 | - * @var charset database |
|
50 | - */ |
|
49 | + * @var charset database |
|
50 | + */ |
|
51 | 51 | protected $charset; |
52 | 52 | |
53 | 53 | /** |
54 | - * @var password database password |
|
55 | - */ |
|
54 | + * @var password database password |
|
55 | + */ |
|
56 | 56 | protected $password; |
57 | 57 | |
58 | 58 | /** |
59 | - * @var connection database |
|
60 | - */ |
|
59 | + * @var connection database |
|
60 | + */ |
|
61 | 61 | protected $connect; |
62 | 62 | |
63 | - /** |
|
64 | - * @method Json_init |
|
65 | - * Create a Json database |
|
66 | - */ |
|
67 | - protected function Json_init() |
|
68 | - { |
|
63 | + /** |
|
64 | + * @method Json_init |
|
65 | + * Create a Json database |
|
66 | + */ |
|
67 | + protected function Json_init() |
|
68 | + { |
|
69 | 69 | $JsonDb = new JsonDb(); |
70 | 70 | $JsonDb->init($this->dbname); |
71 | - } |
|
71 | + } |
|
72 | 72 | |
73 | 73 | |
74 | 74 | |
75 | - } |
|
75 | + } |