@@ -17,8 +17,7 @@ discard block |
||
| 17 | 17 | * |
| 18 | 18 | * @access public |
| 19 | 19 | */ |
| 20 | -class Db extends Generic implements Db_Interface |
|
| 21 | -{ |
|
| 20 | +class Db extends Generic implements Db_Interface { |
|
| 22 | 21 | /** |
| 23 | 22 | * @var string |
| 24 | 23 | */ |
@@ -30,8 +29,7 @@ discard block |
||
| 30 | 29 | * @param string $database the name of the database to use |
| 31 | 30 | * @return void |
| 32 | 31 | */ |
| 33 | - public function useDb($database) |
|
| 34 | - { |
|
| 32 | + public function useDb($database) { |
|
| 35 | 33 | $this->selectDb($database); |
| 36 | 34 | } |
| 37 | 35 | |
@@ -41,8 +39,7 @@ discard block |
||
| 41 | 39 | * @param string $database the name of the database to use |
| 42 | 40 | * @return void |
| 43 | 41 | */ |
| 44 | - public function selectDb($database) |
|
| 45 | - { |
|
| 42 | + public function selectDb($database) { |
|
| 46 | 43 | $this->connect(); |
| 47 | 44 | mysqli_select_db($this->linkId, $database); |
| 48 | 45 | } |
@@ -57,8 +54,7 @@ discard block |
||
| 57 | 54 | * @param string $password |
| 58 | 55 | * @return int|\mysqli |
| 59 | 56 | */ |
| 60 | - public function connect($database = '', $host = '', $user = '', $password = '') |
|
| 61 | - { |
|
| 57 | + public function connect($database = '', $host = '', $user = '', $password = '') { |
|
| 62 | 58 | /* Handle defaults */ |
| 63 | 59 | if ($database == '') { |
| 64 | 60 | $database = $this->database; |
@@ -98,8 +94,7 @@ discard block |
||
| 98 | 94 | * Db::disconnect() |
| 99 | 95 | * @return bool |
| 100 | 96 | */ |
| 101 | - public function disconnect() |
|
| 102 | - { |
|
| 97 | + public function disconnect() { |
|
| 103 | 98 | $return = method_exists($this->linkId, 'close') ? $this->linkId->close() : false; |
| 104 | 99 | $this->linkId = 0; |
| 105 | 100 | return $return; |
@@ -109,8 +104,7 @@ discard block |
||
| 109 | 104 | * @param $string |
| 110 | 105 | * @return string |
| 111 | 106 | */ |
| 112 | - public function real_escape($string = '') |
|
| 113 | - { |
|
| 107 | + public function real_escape($string = '') { |
|
| 114 | 108 | if ((!is_resource($this->linkId) || $this->linkId == 0) && !$this->connect()) { |
| 115 | 109 | return $this->escape($string); |
| 116 | 110 | } |
@@ -121,8 +115,7 @@ discard block |
||
| 121 | 115 | * discard the query result |
| 122 | 116 | * @return void |
| 123 | 117 | */ |
| 124 | - public function free() |
|
| 125 | - { |
|
| 118 | + public function free() { |
|
| 126 | 119 | if (is_resource($this->queryId)) { |
| 127 | 120 | @mysqli_free_result($this->queryId); |
| 128 | 121 | } |
@@ -140,8 +133,7 @@ discard block |
||
| 140 | 133 | * @param string $file optionally pass __FILE__ calling the query for logging |
| 141 | 134 | * @return mixed FALSE if no rows, if a single row it returns that, if multiple it returns an array of rows, associative responses only |
| 142 | 135 | */ |
| 143 | - public function queryReturn($query, $line = '', $file = '') |
|
| 144 | - { |
|
| 136 | + public function queryReturn($query, $line = '', $file = '') { |
|
| 145 | 137 | $this->query($query, $line, $file); |
| 146 | 138 | if ($this->num_rows() == 0) { |
| 147 | 139 | return false; |
@@ -167,8 +159,7 @@ discard block |
||
| 167 | 159 | * @param string $file optionally pass __FILE__ calling the query for logging |
| 168 | 160 | * @return mixed FALSE if no rows, if a single row it returns that, if multiple it returns an array of rows, associative responses only |
| 169 | 161 | */ |
| 170 | - public function qr($query, $line = '', $file = '') |
|
| 171 | - { |
|
| 162 | + public function qr($query, $line = '', $file = '') { |
|
| 172 | 163 | return $this->queryReturn($query, $line, $file); |
| 173 | 164 | } |
| 174 | 165 | |
@@ -180,8 +171,7 @@ discard block |
||
| 180 | 171 | * @param string $line |
| 181 | 172 | * @param string $file |
| 182 | 173 | */ |
| 183 | - public function prepare($query, $line = '', $file = '') |
|
| 184 | - { |
|
| 174 | + public function prepare($query, $line = '', $file = '') { |
|
| 185 | 175 | if (!$this->connect()) { |
| 186 | 176 | return 0; |
| 187 | 177 | } |
@@ -203,8 +193,7 @@ discard block |
||
| 203 | 193 | * @param string $file |
| 204 | 194 | * @return mixed 0 if no query or query id handler, safe to ignore this return |
| 205 | 195 | */ |
| 206 | - public function query($queryString, $line = '', $file = '') |
|
| 207 | - { |
|
| 196 | + public function query($queryString, $line = '', $file = '') { |
|
| 208 | 197 | /* No empty queries, please, since PHP4 chokes on them. */ |
| 209 | 198 | /* The empty query string is passed on from the constructor, |
| 210 | 199 | * when calling the class without a query, e.g. in situations |
@@ -260,8 +249,7 @@ discard block |
||
| 260 | 249 | /** |
| 261 | 250 | * @return array|null|object |
| 262 | 251 | */ |
| 263 | - public function fetchObject() |
|
| 264 | - { |
|
| 252 | + public function fetchObject() { |
|
| 265 | 253 | $this->Record = @mysqli_fetch_object($this->queryId); |
| 266 | 254 | return $this->Record; |
| 267 | 255 | } |
@@ -274,8 +262,7 @@ discard block |
||
| 274 | 262 | * @param mixed $resultType |
| 275 | 263 | * @return bool |
| 276 | 264 | */ |
| 277 | - public function next_record($resultType = MYSQLI_BOTH) |
|
| 278 | - { |
|
| 265 | + public function next_record($resultType = MYSQLI_BOTH) { |
|
| 279 | 266 | if ($this->queryId === false) { |
| 280 | 267 | $this->haltmsg('next_record called with no query pending.'); |
| 281 | 268 | return 0; |
@@ -299,8 +286,7 @@ discard block |
||
| 299 | 286 | * @param integer $pos the row numbe starting at 0 to switch to |
| 300 | 287 | * @return bool whetherit was successfu or not. |
| 301 | 288 | */ |
| 302 | - public function seek($pos = 0) |
|
| 303 | - { |
|
| 289 | + public function seek($pos = 0) { |
|
| 304 | 290 | $status = @mysqli_data_seek($this->queryId, $pos); |
| 305 | 291 | if ($status) { |
| 306 | 292 | $this->Row = $pos; |
@@ -320,8 +306,7 @@ discard block |
||
| 320 | 306 | * |
| 321 | 307 | * @return bool |
| 322 | 308 | */ |
| 323 | - public function transactionBegin() |
|
| 324 | - { |
|
| 309 | + public function transactionBegin() { |
|
| 325 | 310 | if (version_compare(PHP_VERSION, '5.5.0') < 0) { |
| 326 | 311 | return true; |
| 327 | 312 | } |
@@ -336,8 +321,7 @@ discard block |
||
| 336 | 321 | * |
| 337 | 322 | * @return bool |
| 338 | 323 | */ |
| 339 | - public function transactionCommit() |
|
| 340 | - { |
|
| 324 | + public function transactionCommit() { |
|
| 341 | 325 | if (version_compare(PHP_VERSION, '5.5.0') < 0 || $this->linkId === 0) { |
| 342 | 326 | return true; |
| 343 | 327 | } |
@@ -349,8 +333,7 @@ discard block |
||
| 349 | 333 | * |
| 350 | 334 | * @return bool |
| 351 | 335 | */ |
| 352 | - public function transactionAbort() |
|
| 353 | - { |
|
| 336 | + public function transactionAbort() { |
|
| 354 | 337 | if (version_compare(PHP_VERSION, '5.5.0') < 0 || $this->linkId === 0) { |
| 355 | 338 | return true; |
| 356 | 339 | } |
@@ -366,8 +349,7 @@ discard block |
||
| 366 | 349 | * @param string $field |
| 367 | 350 | * @return int|string |
| 368 | 351 | */ |
| 369 | - public function getLastInsertId($table, $field) |
|
| 370 | - { |
|
| 352 | + public function getLastInsertId($table, $field) { |
|
| 371 | 353 | if (!isset($table) || $table == '' || !isset($field) || $field == '') { |
| 372 | 354 | return -1; |
| 373 | 355 | } |
@@ -383,8 +365,7 @@ discard block |
||
| 383 | 365 | * @param string $mode |
| 384 | 366 | * @return bool|int|\mysqli_result |
| 385 | 367 | */ |
| 386 | - public function lock($table, $mode = 'write') |
|
| 387 | - { |
|
| 368 | + public function lock($table, $mode = 'write') { |
|
| 388 | 369 | $this->connect(); |
| 389 | 370 | $query = 'lock tables '; |
| 390 | 371 | if (is_array($table)) { |
@@ -412,8 +393,7 @@ discard block |
||
| 412 | 393 | * @param bool $haltOnError optional, defaults to TRUE, whether or not to halt on error |
| 413 | 394 | * @return bool|int|\mysqli_result |
| 414 | 395 | */ |
| 415 | - public function unlock($haltOnError = true) |
|
| 416 | - { |
|
| 396 | + public function unlock($haltOnError = true) { |
|
| 417 | 397 | $this->connect(); |
| 418 | 398 | |
| 419 | 399 | $res = @mysqli_query($this->linkId, 'unlock tables'); |
@@ -430,8 +410,7 @@ discard block |
||
| 430 | 410 | * Db::affectedRows() |
| 431 | 411 | * @return int |
| 432 | 412 | */ |
| 433 | - public function affectedRows() |
|
| 434 | - { |
|
| 413 | + public function affectedRows() { |
|
| 435 | 414 | return @mysqli_affected_rows($this->linkId); |
| 436 | 415 | } |
| 437 | 416 | |
@@ -439,8 +418,7 @@ discard block |
||
| 439 | 418 | * Db::num_rows() |
| 440 | 419 | * @return int |
| 441 | 420 | */ |
| 442 | - public function num_rows() |
|
| 443 | - { |
|
| 421 | + public function num_rows() { |
|
| 444 | 422 | return @mysqli_num_rows($this->queryId); |
| 445 | 423 | } |
| 446 | 424 | |
@@ -448,8 +426,7 @@ discard block |
||
| 448 | 426 | * Db::num_fields() |
| 449 | 427 | * @return int |
| 450 | 428 | */ |
| 451 | - public function num_fields() |
|
| 452 | - { |
|
| 429 | + public function num_fields() { |
|
| 453 | 430 | return @mysqli_num_fields($this->queryId); |
| 454 | 431 | } |
| 455 | 432 | |
@@ -458,8 +435,7 @@ discard block |
||
| 458 | 435 | * |
| 459 | 436 | * @return array |
| 460 | 437 | */ |
| 461 | - public function tableNames() |
|
| 462 | - { |
|
| 438 | + public function tableNames() { |
|
| 463 | 439 | $return = []; |
| 464 | 440 | $this->query('SHOW TABLES'); |
| 465 | 441 | $i = 0; |