@@ -12,8 +12,7 @@ discard block |
||
| 12 | 12 | /** |
| 13 | 13 | * Class Generic |
| 14 | 14 | */ |
| 15 | -abstract class Generic |
|
| 16 | -{ |
|
| 15 | +abstract class Generic { |
|
| 17 | 16 | /* public: connection parameters */ |
| 18 | 17 | public $host = 'localhost'; |
| 19 | 18 | public $database = ''; |
@@ -63,8 +62,7 @@ discard block |
||
| 63 | 62 | * @param string $host Optional The hostname where the server is, or default to localhost |
| 64 | 63 | * @param string $query Optional query to perform immediately |
| 65 | 64 | */ |
| 66 | - public function __construct($database = '', $user = '', $password = '', $host = 'localhost', $query = '') |
|
| 67 | - { |
|
| 65 | + public function __construct($database = '', $user = '', $password = '', $host = 'localhost', $query = '') { |
|
| 68 | 66 | $this->database = $database; |
| 69 | 67 | $this->user = $user; |
| 70 | 68 | $this->password = $password; |
@@ -81,24 +79,21 @@ discard block |
||
| 81 | 79 | * @param string $file |
| 82 | 80 | * @return void |
| 83 | 81 | */ |
| 84 | - public function log($message, $line = '', $file = '', $level = 'info') |
|
| 85 | - { |
|
| 82 | + public function log($message, $line = '', $file = '', $level = 'info') { |
|
| 86 | 83 | error_log($message); |
| 87 | 84 | } |
| 88 | 85 | |
| 89 | 86 | /** |
| 90 | 87 | * @return int|object |
| 91 | 88 | */ |
| 92 | - public function linkId() |
|
| 93 | - { |
|
| 89 | + public function linkId() { |
|
| 94 | 90 | return $this->linkId; |
| 95 | 91 | } |
| 96 | 92 | |
| 97 | 93 | /** |
| 98 | 94 | * @return int|object |
| 99 | 95 | */ |
| 100 | - public function queryId() |
|
| 101 | - { |
|
| 96 | + public function queryId() { |
|
| 102 | 97 | return $this->queryId; |
| 103 | 98 | } |
| 104 | 99 | |
@@ -106,8 +101,7 @@ discard block |
||
| 106 | 101 | * @param $string |
| 107 | 102 | * @return string |
| 108 | 103 | */ |
| 109 | - public function real_escape($string = '') |
|
| 110 | - { |
|
| 104 | + public function real_escape($string = '') { |
|
| 111 | 105 | if ((!is_resource($this->linkId) || $this->linkId == 0) && !$this->connect()) { |
| 112 | 106 | return $this->escape($string); |
| 113 | 107 | } |
@@ -118,8 +112,7 @@ discard block |
||
| 118 | 112 | * @param $string |
| 119 | 113 | * @return string |
| 120 | 114 | */ |
| 121 | - public function escape($string = '') |
|
| 122 | - { |
|
| 115 | + public function escape($string = '') { |
|
| 123 | 116 | //if (function_exists('mysql_escape_string')) |
| 124 | 117 | //return mysql_escape_string($string); |
| 125 | 118 | return str_replace(array('\\', "\0", "\n", "\r", "'", '"', "\x1a"), array('\\\\', '\\0', '\\n', '\\r', "\\'", '\\"', '\\Z'), $string); |
@@ -129,8 +122,7 @@ discard block |
||
| 129 | 122 | * @param mixed $str |
| 130 | 123 | * @return string |
| 131 | 124 | */ |
| 132 | - public function dbAddslashes($str = '') |
|
| 133 | - { |
|
| 125 | + public function dbAddslashes($str = '') { |
|
| 134 | 126 | if (!isset($str) || $str == '') { |
| 135 | 127 | return ''; |
| 136 | 128 | } |
@@ -142,8 +134,7 @@ discard block |
||
| 142 | 134 | * @param mixed $epoch |
| 143 | 135 | * @return bool|string |
| 144 | 136 | */ |
| 145 | - public function toTimestamp($epoch) |
|
| 146 | - { |
|
| 137 | + public function toTimestamp($epoch) { |
|
| 147 | 138 | return date('Y-m-d H:i:s', $epoch); |
| 148 | 139 | } |
| 149 | 140 | |
@@ -152,8 +143,7 @@ discard block |
||
| 152 | 143 | * @param mixed $timestamp |
| 153 | 144 | * @return bool|int|mixed |
| 154 | 145 | */ |
| 155 | - public function fromTimestamp($timestamp) |
|
| 156 | - { |
|
| 146 | + public function fromTimestamp($timestamp) { |
|
| 157 | 147 | if (preg_match('/([0-9]{4})-([0-9]{2})-([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2})/', $timestamp, $parts)) { |
| 158 | 148 | $time = mktime($parts[4], $parts[5], $parts[6], $parts[2], $parts[3], $parts[1]); |
| 159 | 149 | } elseif (preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/', $timestamp, $parts)) { |
@@ -179,8 +169,7 @@ discard block |
||
| 179 | 169 | * @param string $file |
| 180 | 170 | * @return mixed |
| 181 | 171 | */ |
| 182 | - public function limitQuery($queryString, $numRows = '', $offset = 0, $line = '', $file = '') |
|
| 183 | - { |
|
| 172 | + public function limitQuery($queryString, $numRows = '', $offset = 0, $line = '', $file = '') { |
|
| 184 | 173 | if (!$numRows) { |
| 185 | 174 | $numRows = $this->maxMatches; |
| 186 | 175 | } |
@@ -207,8 +196,7 @@ discard block |
||
| 207 | 196 | * @param string $file optionally pass __FILE__ calling the query for logging |
| 208 | 197 | * @return mixed FALSE if no rows, if a single row it returns that, if multiple it returns an array of rows, associative responses only |
| 209 | 198 | */ |
| 210 | - public function qr($query, $line = '', $file = '') |
|
| 211 | - { |
|
| 199 | + public function qr($query, $line = '', $file = '') { |
|
| 212 | 200 | return $this->queryReturn($query, $line, $file); |
| 213 | 201 | } |
| 214 | 202 | |
@@ -219,8 +207,7 @@ discard block |
||
| 219 | 207 | * @param string $stripSlashes |
| 220 | 208 | * @return string |
| 221 | 209 | */ |
| 222 | - public function f($name, $stripSlashes = '') |
|
| 223 | - { |
|
| 210 | + public function f($name, $stripSlashes = '') { |
|
| 224 | 211 | if ($stripSlashes || ($this->autoStripslashes && !$stripSlashes)) { |
| 225 | 212 | return stripslashes($this->Record[$name]); |
| 226 | 213 | } else { |
@@ -236,8 +223,7 @@ discard block |
||
| 236 | 223 | * @param string $file |
| 237 | 224 | * @return void |
| 238 | 225 | */ |
| 239 | - public function halt($msg, $line = '', $file = '') |
|
| 240 | - { |
|
| 226 | + public function halt($msg, $line = '', $file = '') { |
|
| 241 | 227 | $this->unlock(false); |
| 242 | 228 | /* Just in case there is a table currently locked */ |
| 243 | 229 | |
@@ -265,8 +251,7 @@ discard block |
||
| 265 | 251 | * @param string $file |
| 266 | 252 | * @return mixed|void |
| 267 | 253 | */ |
| 268 | - public function logBackTrace($msg, $line = '', $file = '') |
|
| 269 | - { |
|
| 254 | + public function logBackTrace($msg, $line = '', $file = '') { |
|
| 270 | 255 | $backtrace = (function_exists('debug_backtrace') ? debug_backtrace() : []); |
| 271 | 256 | $this->log( |
| 272 | 257 | ('' !== getenv('REQUEST_URI') ? ' '.getenv('REQUEST_URI') : ''). |
@@ -297,8 +282,7 @@ discard block |
||
| 297 | 282 | } |
| 298 | 283 | } |
| 299 | 284 | |
| 300 | - public function emailError($queryString, $error, $line, $file) |
|
| 301 | - { |
|
| 285 | + public function emailError($queryString, $error, $line, $file) { |
|
| 302 | 286 | $subject = php_uname('n').' MySQLi Error'; |
| 303 | 287 | $smarty = new \TFSmarty(); |
| 304 | 288 | $smarty->assign([ |
@@ -325,8 +309,7 @@ discard block |
||
| 325 | 309 | * @param string $file |
| 326 | 310 | * @return mixed|void |
| 327 | 311 | */ |
| 328 | - public function haltmsg($msg, $line = '', $file = '') |
|
| 329 | - { |
|
| 312 | + public function haltmsg($msg, $line = '', $file = '') { |
|
| 330 | 313 | $this->log("Database error: $msg", $line, $file, 'error'); |
| 331 | 314 | if ($this->Errno != '0' || !in_array($this->Error, ['', '()'])) { |
| 332 | 315 | $sqlstate = mysqli_sqlstate($this->linkId); |
@@ -338,8 +321,7 @@ discard block |
||
| 338 | 321 | /** |
| 339 | 322 | * @return array |
| 340 | 323 | */ |
| 341 | - public function indexNames() |
|
| 342 | - { |
|
| 324 | + public function indexNames() { |
|
| 343 | 325 | return []; |
| 344 | 326 | } |
| 345 | 327 | } |