@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | /** |
16 | 16 | * Class PDOMySQLDriver |
17 | 17 | */ |
18 | -class PDOMySQLDriver extends PDODriver implements DBDriverInterface{ |
|
18 | +class PDOMySQLDriver extends PDODriver implements DBDriverInterface { |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * The PDO drivername which is being used in the DSN |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * |
30 | 30 | * @return string DSN |
31 | 31 | */ |
32 | - protected function getDSN(){ |
|
32 | + protected function getDSN() { |
|
33 | 33 | // the charset option is specific to mysql |
34 | 34 | return parent::getDSN().';charset='.$this->options->mysql_charset; |
35 | 35 | } |
@@ -15,7 +15,7 @@ |
||
15 | 15 | /** |
16 | 16 | * Class PDOODBCDriver |
17 | 17 | */ |
18 | -class PDOODBCDriver extends PDODriver implements DBDriverInterface{ |
|
18 | +class PDOODBCDriver extends PDODriver implements DBDriverInterface { |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * The PDO drivername which is being used in the DSN |
@@ -15,7 +15,7 @@ |
||
15 | 15 | /** |
16 | 16 | * Class PDOPostgresDriver |
17 | 17 | */ |
18 | -class PDOPostgresDriver extends PDODriver implements DBDriverInterface{ |
|
18 | +class PDOPostgresDriver extends PDODriver implements DBDriverInterface { |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * The PDO drivername which is being used in the DSN |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | /** |
16 | 16 | * Class PDOSQLiteDriver |
17 | 17 | */ |
18 | -class PDOSQLiteDriver extends PDODriver implements DBDriverInterface{ |
|
18 | +class PDOSQLiteDriver extends PDODriver implements DBDriverInterface { |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * The PDO drivername which is being used in the DSN |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @return string DSN |
32 | 32 | */ |
33 | - protected function getDSN(){ |
|
33 | + protected function getDSN() { |
|
34 | 34 | return $this->drivername.':'.$this->options->database; |
35 | 35 | } |
36 | 36 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * |
40 | 40 | * @return string database's serverinfo string |
41 | 41 | */ |
42 | - public function getServerInfo(){ |
|
42 | + public function getServerInfo() { |
|
43 | 43 | return $this->drivername.' (PDO::ATTR_SERVER_INFO not available)'; |
44 | 44 | } |
45 | 45 |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | /** |
19 | 19 | * Class PostgreSQLDriver |
20 | 20 | */ |
21 | -class PostgreSQLDriver extends DBBaseDriver implements DBDriverInterface{ |
|
21 | +class PostgreSQLDriver extends DBBaseDriver implements DBDriverInterface { |
|
22 | 22 | |
23 | 23 | /** |
24 | 24 | * Holds the database resource object |
@@ -33,9 +33,9 @@ discard block |
||
33 | 33 | * @return resource the database resource object |
34 | 34 | * @throws \chillerlan\Database\DBException |
35 | 35 | */ |
36 | - public function connect(){ |
|
36 | + public function connect() { |
|
37 | 37 | |
38 | - if(gettype($this->db) === 'resource'){ |
|
38 | + if (gettype($this->db) === 'resource') { |
|
39 | 39 | return $this->db; |
40 | 40 | } |
41 | 41 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | 'options=\''.implode(' ', $options).'\'', |
55 | 55 | ]; |
56 | 56 | |
57 | - if(!$this->db = pg_connect(implode(' ', $conn_str))){ |
|
57 | + if (!$this->db = pg_connect(implode(' ', $conn_str))) { |
|
58 | 58 | throw new DBException('Could not connect to the database.'); |
59 | 59 | } |
60 | 60 | |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @return $this |
68 | 68 | */ |
69 | - public function disconnect(){ |
|
69 | + public function disconnect() { |
|
70 | 70 | pg_close($this->db); |
71 | 71 | } |
72 | 72 | |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | * |
76 | 76 | * @return string php's database client string |
77 | 77 | */ |
78 | - public function getClientInfo(){ |
|
78 | + public function getClientInfo() { |
|
79 | 79 | $ver = pg_version($this->db); |
80 | 80 | |
81 | 81 | return 'PostgreSQL '.$ver['client'].' ('.$ver['client_encoding'].')'; |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * |
87 | 87 | * @return string database's serverinfo string |
88 | 88 | */ |
89 | - public function getServerInfo(){ |
|
89 | + public function getServerInfo() { |
|
90 | 90 | $ver = pg_version($this->db); |
91 | 91 | |
92 | 92 | return 'PostgreSQL '.$ver['server'].' ('.$ver['server_encoding'].', date style: '.$ver['DateStyle'].', time zone: '.$ver['TimeZone'].')'; |
@@ -102,25 +102,25 @@ discard block |
||
102 | 102 | * |
103 | 103 | * @return array|string array or string. escaped. obviously. |
104 | 104 | */ |
105 | - public function escape($data, $specialchars = false){ |
|
105 | + public function escape($data, $specialchars = false) { |
|
106 | 106 | |
107 | - if(is_array($data)){ |
|
107 | + if (is_array($data)) { |
|
108 | 108 | |
109 | - foreach($data as $key => $value){ |
|
109 | + foreach ($data as $key => $value) { |
|
110 | 110 | $data[$key] = $this->escape($value, $specialchars); |
111 | 111 | } |
112 | 112 | |
113 | 113 | } |
114 | - else if(is_object($data)){ |
|
114 | + else if (is_object($data)) { |
|
115 | 115 | |
116 | - foreach($data as $key => $value){ |
|
116 | + foreach ($data as $key => $value) { |
|
117 | 117 | $data->{$key} = $this->escape($value, $specialchars); |
118 | 118 | } |
119 | 119 | |
120 | 120 | } |
121 | - else{ |
|
121 | + else { |
|
122 | 122 | |
123 | - if($specialchars){ |
|
123 | + if ($specialchars) { |
|
124 | 124 | $data = htmlspecialchars($data, ENT_HTML5, 'UTF-8', false); |
125 | 125 | } |
126 | 126 | |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | * @return array|bool array with results, true on void query success, otherwise false. |
148 | 148 | * @throws \mysqli_sql_exception |
149 | 149 | */ |
150 | - public function raw($sql, $index = '', $assoc = true, $fetch_array = false){ |
|
150 | + public function raw($sql, $index = '', $assoc = true, $fetch_array = false) { |
|
151 | 151 | // TODO: Implement raw() method. |
152 | 152 | } |
153 | 153 | |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | * |
166 | 166 | * @return array|bool Array with results, true on void query success, otherwise false |
167 | 167 | */ |
168 | - public function prepared($sql, array $values = [], $index = '', $assoc = true, $fetch_array = false){ |
|
168 | + public function prepared($sql, array $values = [], $index = '', $assoc = true, $fetch_array = false) { |
|
169 | 169 | // TODO: Implement prepared() method. |
170 | 170 | } |
171 | 171 | |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | * |
180 | 180 | * @return bool true query success, otherwise false |
181 | 181 | */ |
182 | - public function multi($sql, array $values){ |
|
182 | + public function multi($sql, array $values) { |
|
183 | 183 | // TODO: Implement multi() method. |
184 | 184 | } |
185 | 185 | } |
@@ -110,15 +110,13 @@ |
||
110 | 110 | $data[$key] = $this->escape($value, $specialchars); |
111 | 111 | } |
112 | 112 | |
113 | - } |
|
114 | - else if(is_object($data)){ |
|
113 | + } else if(is_object($data)){ |
|
115 | 114 | |
116 | 115 | foreach($data as $key => $value){ |
117 | 116 | $data->{$key} = $this->escape($value, $specialchars); |
118 | 117 | } |
119 | 118 | |
120 | - } |
|
121 | - else{ |
|
119 | + } else{ |
|
122 | 120 | |
123 | 121 | if($specialchars){ |
124 | 122 | $data = htmlspecialchars($data, ENT_HTML5, 'UTF-8', false); |
@@ -1,14 +1,14 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Class Querystats |
|
4 | - * |
|
5 | - * @filesource Querystats.php |
|
6 | - * @created 05.11.2015 |
|
7 | - * @package chillerlan\Database |
|
8 | - * @author Smiley <[email protected]> |
|
9 | - * @copyright 2015 Smiley |
|
10 | - * @license MIT |
|
11 | - */ |
|
3 | + * Class Querystats |
|
4 | + * |
|
5 | + * @filesource Querystats.php |
|
6 | + * @created 05.11.2015 |
|
7 | + * @package chillerlan\Database |
|
8 | + * @author Smiley <[email protected]> |
|
9 | + * @copyright 2015 Smiley |
|
10 | + * @license MIT |
|
11 | + */ |
|
12 | 12 | |
13 | 13 | namespace chillerlan\Database; |
14 | 14 |
@@ -15,7 +15,7 @@ |
||
15 | 15 | /** |
16 | 16 | * A result class to hold statistics for a query |
17 | 17 | */ |
18 | -class Querystats{ |
|
18 | +class Querystats { |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * Affected rows of the last query. |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | /** |
19 | 19 | * A simple class loader |
20 | 20 | */ |
21 | -trait ClassLoaderTrait{ |
|
21 | +trait ClassLoaderTrait { |
|
22 | 22 | |
23 | 23 | /** |
24 | 24 | * A simple class loader |
@@ -31,12 +31,12 @@ discard block |
||
31 | 31 | * @return object of type $interface |
32 | 32 | * @throws \chillerlan\Database\DBException |
33 | 33 | */ |
34 | - protected function __loadClass($class, $interface, ...$params){ // phpDocumentor stumbles across the ... syntax |
|
34 | + protected function __loadClass($class, $interface, ...$params) { // phpDocumentor stumbles across the ... syntax |
|
35 | 35 | |
36 | - if(class_exists($class)){ |
|
36 | + if (class_exists($class)) { |
|
37 | 37 | $reflectionClass = new ReflectionClass($class); |
38 | 38 | |
39 | - if(!$reflectionClass->implementsInterface($interface)) { |
|
39 | + if (!$reflectionClass->implementsInterface($interface)) { |
|
40 | 40 | throw new DBException($class.' does not implement '.$interface); |
41 | 41 | } |
42 | 42 |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | /** |
19 | 19 | * Note: this trait also includes the ClassLoader trait |
20 | 20 | */ |
21 | -trait DatabaseTrait{ |
|
21 | +trait DatabaseTrait { |
|
22 | 22 | use ClassLoaderTrait; |
23 | 23 | |
24 | 24 | /** |
@@ -37,9 +37,9 @@ discard block |
||
37 | 37 | * |
38 | 38 | * @return \chillerlan\Database\Drivers\DBDriverInterface |
39 | 39 | */ |
40 | - protected function dbconnect($driver, DBOptions $options = null){ |
|
40 | + protected function dbconnect($driver, DBOptions $options = null) { |
|
41 | 41 | |
42 | - if(!$options){ |
|
42 | + if (!$options) { |
|
43 | 43 | $options = new DBOptions; |
44 | 44 | } |
45 | 45 |