Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like DB often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use DB, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 13 | final class DB |
||
| 14 | { |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @var int |
||
| 18 | */ |
||
| 19 | public $query_count = 0; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @var \mysqli |
||
| 23 | */ |
||
| 24 | private $link = false; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @var bool |
||
| 28 | */ |
||
| 29 | private $connected = false; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @var array |
||
| 33 | */ |
||
| 34 | private $mysqlDefaultTimeFunctions; |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @var string |
||
| 38 | */ |
||
| 39 | private $hostname = ''; |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @var string |
||
| 43 | */ |
||
| 44 | private $username = ''; |
||
| 45 | |||
| 46 | /** |
||
| 47 | * @var string |
||
| 48 | */ |
||
| 49 | private $password = ''; |
||
| 50 | |||
| 51 | /** |
||
| 52 | * @var string |
||
| 53 | */ |
||
| 54 | private $database = ''; |
||
| 55 | |||
| 56 | /** |
||
| 57 | * @var int |
||
| 58 | */ |
||
| 59 | private $port = 3306; |
||
| 60 | |||
| 61 | /** |
||
| 62 | * @var string |
||
| 63 | */ |
||
| 64 | private $charset = 'utf8'; |
||
| 65 | |||
| 66 | /** |
||
| 67 | * @var string |
||
| 68 | */ |
||
| 69 | private $socket = ''; |
||
| 70 | |||
| 71 | /** |
||
| 72 | * @var bool |
||
| 73 | */ |
||
| 74 | private $session_to_db = false; |
||
| 75 | |||
| 76 | /** |
||
| 77 | * @var bool |
||
| 78 | */ |
||
| 79 | private $_in_transaction = false; |
||
| 80 | |||
| 81 | /** |
||
| 82 | * @var bool |
||
| 83 | */ |
||
| 84 | private $_convert_null_to_empty_string = false; |
||
| 85 | |||
| 86 | /** |
||
| 87 | * @var Debug |
||
| 88 | */ |
||
| 89 | private $_debug; |
||
| 90 | |||
| 91 | /** |
||
| 92 | * __construct() |
||
| 93 | * |
||
| 94 | * @param string $hostname |
||
| 95 | * @param string $username |
||
| 96 | * @param string $password |
||
| 97 | * @param string $database |
||
| 98 | * @param int $port |
||
| 99 | * @param string $charset |
||
| 100 | * @param boolean|string $exit_on_error use a empty string "" or false to disable it |
||
| 101 | * @param boolean|string $echo_on_error use a empty string "" or false to disable it |
||
| 102 | * @param string $logger_class_name |
||
| 103 | * @param string $logger_level 'TRACE', 'DEBUG', 'INFO', 'WARN', 'ERROR', 'FATAL' |
||
| 104 | * @param boolean|string $session_to_db use a empty string "" or false to disable it |
||
| 105 | */ |
||
| 106 | 10 | protected function __construct($hostname, $username, $password, $database, $port, $charset, $exit_on_error, $echo_on_error, $logger_class_name, $logger_level, $session_to_db) |
|
| 157 | |||
| 158 | /** |
||
| 159 | * Load the config from the constructor. |
||
| 160 | * |
||
| 161 | * @param string $hostname |
||
| 162 | * @param string $username |
||
| 163 | * @param string $password |
||
| 164 | * @param string $database |
||
| 165 | * @param int $port |
||
| 166 | * @param string $charset |
||
| 167 | * @param boolean|string $exit_on_error use a empty string "" or false to disable it |
||
| 168 | * @param boolean|string $echo_on_error use a empty string "" or false to disable it |
||
| 169 | * @param string $logger_class_name |
||
| 170 | * @param string $logger_level |
||
| 171 | * @param boolean|string $session_to_db use a empty string "" or false to disable it |
||
| 172 | * |
||
| 173 | * @return bool |
||
| 174 | */ |
||
| 175 | 10 | private function _loadConfig($hostname, $username, $password, $database, $port, $charset, $exit_on_error, $echo_on_error, $logger_class_name, $logger_level, $session_to_db) |
|
| 218 | |||
| 219 | /** |
||
| 220 | * Show config errors by throw exceptions. |
||
| 221 | * |
||
| 222 | * @return bool |
||
| 223 | * |
||
| 224 | * @throws \Exception |
||
| 225 | */ |
||
| 226 | 10 | public function showConfigError() |
|
| 254 | |||
| 255 | /** |
||
| 256 | * Open a new connection to the MySQL server. |
||
| 257 | * |
||
| 258 | * @return boolean |
||
| 259 | */ |
||
| 260 | 9 | public function connect() |
|
| 297 | |||
| 298 | /** |
||
| 299 | * Check if db-connection is ready. |
||
| 300 | * |
||
| 301 | * @return boolean |
||
| 302 | */ |
||
| 303 | 44 | public function isReady() |
|
| 307 | |||
| 308 | /** |
||
| 309 | * Get a new "Prepare"-Object for your sql-query. |
||
| 310 | * |
||
| 311 | * @param string $query |
||
| 312 | * |
||
| 313 | * @return Prepare |
||
| 314 | */ |
||
| 315 | 2 | public function prepare($query) |
|
| 319 | |||
| 320 | /** |
||
| 321 | * Execute a sql-query and return the result-array for select-statements. |
||
| 322 | * |
||
| 323 | * @param $query |
||
| 324 | * |
||
| 325 | * @return mixed |
||
| 326 | * @deprecated |
||
| 327 | * @throws \Exception |
||
| 328 | */ |
||
| 329 | public static function qry($query) |
||
| 330 | { |
||
| 331 | $db = self::getInstance(); |
||
| 332 | |||
| 333 | $args = func_get_args(); |
||
| 334 | /** @noinspection SuspiciousAssignmentsInspection */ |
||
| 335 | $query = array_shift($args); |
||
| 336 | $query = str_replace('?', '%s', $query); |
||
| 337 | $args = array_map( |
||
| 338 | array( |
||
| 339 | $db, |
||
| 340 | 'escape', |
||
| 341 | ), |
||
| 342 | $args |
||
| 343 | ); |
||
| 344 | array_unshift($args, $query); |
||
| 345 | $query = call_user_func_array('sprintf', $args); |
||
| 346 | $result = $db->query($query); |
||
| 347 | |||
| 348 | if ($result instanceof Result) { |
||
| 349 | return $result->fetchAllArray(); |
||
| 350 | } |
||
| 351 | |||
| 352 | return $result; |
||
| 353 | } |
||
| 354 | |||
| 355 | /** |
||
| 356 | * getInstance() |
||
| 357 | * |
||
| 358 | * @param string $hostname |
||
| 359 | * @param string $username |
||
| 360 | * @param string $password |
||
| 361 | * @param string $database |
||
| 362 | * @param string $port default is (int)3306 |
||
| 363 | * @param string $charset default is 'utf8' or 'utf8mb4' (if supported) |
||
| 364 | * @param bool|string $exit_on_error use a empty string "" or false to disable it |
||
| 365 | * @param bool|string $echo_on_error use a empty string "" or false to disable it |
||
| 366 | * @param string $logger_class_name |
||
| 367 | * @param string $logger_level |
||
| 368 | * @param bool|string $session_to_db use a empty string "" or false to disable it |
||
| 369 | * |
||
| 370 | * @return \voku\db\DB |
||
| 371 | */ |
||
| 372 | 56 | public static function getInstance($hostname = '', $username = '', $password = '', $database = '', $port = '', $charset = '', $exit_on_error = '', $echo_on_error = '', $logger_class_name = '', $logger_level = '', $session_to_db = '') |
|
| 418 | |||
| 419 | /** |
||
| 420 | * Execute a sql-query. |
||
| 421 | * |
||
| 422 | * @param string $sql sql-query |
||
| 423 | * |
||
| 424 | * @param array|boolean $params "array" of sql-query-parameters |
||
| 425 | * "false" if you don't need any parameter (default) |
||
| 426 | * |
||
| 427 | * @return bool|int|Result "Result" by "<b>SELECT</b>"-queries<br /> |
||
| 428 | * "int" (insert_id) by "<b>INSERT / REPLACE</b>"-queries<br /> |
||
| 429 | * "int" (affected_rows) by "<b>UPDATE / DELETE</b>"-queries<br /> |
||
| 430 | * "true" by e.g. "DROP"-queries<br /> |
||
| 431 | * "false" on error |
||
| 432 | * |
||
| 433 | * @throws \Exception |
||
| 434 | */ |
||
| 435 | 34 | public function query($sql = '', $params = false) |
|
| 509 | |||
| 510 | /** |
||
| 511 | * _parseQueryParams |
||
| 512 | * |
||
| 513 | * @param string $sql |
||
| 514 | * @param array $params |
||
| 515 | * |
||
| 516 | * @return string |
||
| 517 | */ |
||
| 518 | 3 | private function _parseQueryParams($sql, array $params) |
|
| 539 | |||
| 540 | /** |
||
| 541 | * Try to secure a variable, so can you use it in sql-queries. |
||
| 542 | * |
||
| 543 | * <p> |
||
| 544 | * <strong>int:</strong> (also strings that contains only an int-value)<br /> |
||
| 545 | * 1. parse into "int" |
||
| 546 | * </p><br /> |
||
| 547 | * |
||
| 548 | * <p> |
||
| 549 | * <strong>float:</strong><br /> |
||
| 550 | * 1. return "float" |
||
| 551 | * </p><br /> |
||
| 552 | * |
||
| 553 | * <p> |
||
| 554 | * <strong>string:</strong><br /> |
||
| 555 | * 1. check if the string isn't a default mysql-time-function e.g. 'CURDATE()'<br /> |
||
| 556 | * 2. trim whitespace<br /> |
||
| 557 | * 3. trim '<br /> |
||
| 558 | * 4. escape the string (and remove non utf-8 chars)<br /> |
||
| 559 | * 5. trim ' again (because we maybe removed some chars)<br /> |
||
| 560 | * 6. add ' around the new string<br /> |
||
| 561 | * </p><br /> |
||
| 562 | * |
||
| 563 | * <p> |
||
| 564 | * <strong>array:</strong><br /> |
||
| 565 | * 1. return null |
||
| 566 | * </p><br /> |
||
| 567 | * |
||
| 568 | * <p> |
||
| 569 | * <strong>object:</strong><br /> |
||
| 570 | * 1. return false |
||
| 571 | * </p><br /> |
||
| 572 | * |
||
| 573 | * <p> |
||
| 574 | * <strong>null:</strong><br /> |
||
| 575 | * 1. return null |
||
| 576 | * </p> |
||
| 577 | * |
||
| 578 | * @param mixed $var |
||
| 579 | * |
||
| 580 | * @return mixed |
||
| 581 | */ |
||
| 582 | 25 | public function secure($var) |
|
| 608 | |||
| 609 | /** |
||
| 610 | * Escape: Use "mysqli_real_escape_string" and clean non UTF-8 chars + some extra optional stuff. |
||
| 611 | * |
||
| 612 | * @param mixed $var boolean: convert into "integer"<br /> |
||
| 613 | * int: int (don't change it)<br /> |
||
| 614 | * float: float (don't change it)<br /> |
||
| 615 | * null: null (don't change it)<br /> |
||
| 616 | * array: run escape() for every key => value<br /> |
||
| 617 | * string: run UTF8::cleanup() and mysqli_real_escape_string()<br /> |
||
| 618 | * @param bool $stripe_non_utf8 |
||
| 619 | * @param bool $html_entity_decode |
||
| 620 | * @param bool|null $convert_array <strong>false</strong> => Keep the array.<br /> |
||
| 621 | * <strong>true</strong> => Convert to string var1,var2,var3...<br /> |
||
| 622 | * <strong>null</strong> => Convert the array into null, every time. |
||
| 623 | * |
||
| 624 | * @return mixed |
||
| 625 | */ |
||
| 626 | 32 | public function escape($var = '', $stripe_non_utf8 = true, $html_entity_decode = false, $convert_array = false) |
|
| 740 | |||
| 741 | /** |
||
| 742 | * Get the mysqli-link (link identifier returned by mysqli-connect). |
||
| 743 | * |
||
| 744 | * @return \mysqli |
||
| 745 | */ |
||
| 746 | 34 | public function getLink() |
|
| 750 | |||
| 751 | /** |
||
| 752 | * Returns the auto generated id used in the last query. |
||
| 753 | * |
||
| 754 | * @return int|string |
||
| 755 | */ |
||
| 756 | 21 | public function insert_id() |
|
| 760 | |||
| 761 | /** |
||
| 762 | * Gets the number of affected rows in a previous MySQL operation. |
||
| 763 | * |
||
| 764 | * @return int |
||
| 765 | */ |
||
| 766 | 7 | public function affected_rows() |
|
| 770 | |||
| 771 | /** |
||
| 772 | * Error-handling for the sql-query. |
||
| 773 | * |
||
| 774 | * @param string $errorMsg |
||
| 775 | * @param string $sql |
||
| 776 | * @param array|bool $sqlParams false if there wasn't any parameter |
||
| 777 | * |
||
| 778 | * @throws \Exception |
||
| 779 | * |
||
| 780 | * @return bool |
||
| 781 | */ |
||
| 782 | 9 | View Code Duplication | protected function queryErrorHandling($errorMsg, $sql, $sqlParams = false) |
| 810 | |||
| 811 | /** |
||
| 812 | * Reconnect to the MySQL-Server. |
||
| 813 | * |
||
| 814 | * @param bool $checkViaPing |
||
| 815 | * |
||
| 816 | * @return bool |
||
| 817 | */ |
||
| 818 | 3 | public function reconnect($checkViaPing = false) |
|
| 833 | |||
| 834 | /** |
||
| 835 | * Pings a server connection, or tries to reconnect |
||
| 836 | * if the connection has gone down. |
||
| 837 | * |
||
| 838 | * @return boolean |
||
| 839 | */ |
||
| 840 | 3 | public function ping() |
|
| 853 | |||
| 854 | /** |
||
| 855 | * Execute select/insert/update/delete sql-queries. |
||
| 856 | * |
||
| 857 | * @param string $query sql-query |
||
| 858 | * @param bool $useCache use cache? |
||
| 859 | * @param int $cacheTTL cache-ttl in seconds |
||
| 860 | * |
||
| 861 | * @return mixed "array" by "<b>SELECT</b>"-queries<br /> |
||
| 862 | * "int" (insert_id) by "<b>INSERT</b>"-queries<br /> |
||
| 863 | * "int" (affected_rows) by "<b>UPDATE / DELETE</b>"-queries<br /> |
||
| 864 | * "true" by e.g. "DROP"-queries<br /> |
||
| 865 | * "false" on error |
||
| 866 | */ |
||
| 867 | 3 | public static function execSQL($query, $useCache = false, $cacheTTL = 3600) |
|
| 913 | |||
| 914 | /** |
||
| 915 | * Get the current charset. |
||
| 916 | * |
||
| 917 | * @return string |
||
| 918 | */ |
||
| 919 | 1 | public function get_charset() |
|
| 923 | |||
| 924 | /** |
||
| 925 | * Enables or disables internal report functions |
||
| 926 | * |
||
| 927 | * @link http://php.net/manual/en/function.mysqli-report.php |
||
| 928 | * |
||
| 929 | * @param int $flags <p> |
||
| 930 | * <table> |
||
| 931 | * Supported flags |
||
| 932 | * <tr valign="top"> |
||
| 933 | * <td>Name</td> |
||
| 934 | * <td>Description</td> |
||
| 935 | * </tr> |
||
| 936 | * <tr valign="top"> |
||
| 937 | * <td><b>MYSQLI_REPORT_OFF</b></td> |
||
| 938 | * <td>Turns reporting off</td> |
||
| 939 | * </tr> |
||
| 940 | * <tr valign="top"> |
||
| 941 | * <td><b>MYSQLI_REPORT_ERROR</b></td> |
||
| 942 | * <td>Report errors from mysqli function calls</td> |
||
| 943 | * </tr> |
||
| 944 | * <tr valign="top"> |
||
| 945 | * <td><b>MYSQLI_REPORT_STRICT</b></td> |
||
| 946 | * <td> |
||
| 947 | * Throw <b>mysqli_sql_exception</b> for errors |
||
| 948 | * instead of warnings |
||
| 949 | * </td> |
||
| 950 | * </tr> |
||
| 951 | * <tr valign="top"> |
||
| 952 | * <td><b>MYSQLI_REPORT_INDEX</b></td> |
||
| 953 | * <td>Report if no index or bad index was used in a query</td> |
||
| 954 | * </tr> |
||
| 955 | * <tr valign="top"> |
||
| 956 | * <td><b>MYSQLI_REPORT_ALL</b></td> |
||
| 957 | * <td>Set all options (report all)</td> |
||
| 958 | * </tr> |
||
| 959 | * </table> |
||
| 960 | * </p> |
||
| 961 | * |
||
| 962 | * @return bool |
||
| 963 | */ |
||
| 964 | public function set_mysqli_report($flags) |
||
| 968 | |||
| 969 | /** |
||
| 970 | * Set the current charset. |
||
| 971 | * |
||
| 972 | * @param string $charset |
||
| 973 | * |
||
| 974 | * @return bool |
||
| 975 | */ |
||
| 976 | 7 | public function set_charset($charset) |
|
| 996 | |||
| 997 | /** |
||
| 998 | * Set the option to convert null to "''" (empty string). |
||
| 999 | * |
||
| 1000 | * Used in secure() => select(), insert(), update(), delete() |
||
| 1001 | * |
||
| 1002 | * @param $bool |
||
| 1003 | */ |
||
| 1004 | 1 | public function set_convert_null_to_empty_string($bool) |
|
| 1008 | |||
| 1009 | /** |
||
| 1010 | * Get all table-names via "SHOW TABLES". |
||
| 1011 | * |
||
| 1012 | * @return array |
||
| 1013 | */ |
||
| 1014 | 1 | public function getAllTables() |
|
| 1021 | |||
| 1022 | /** |
||
| 1023 | * Execute a sql-multi-query. |
||
| 1024 | * |
||
| 1025 | * @param string $sql |
||
| 1026 | * |
||
| 1027 | * @return false|Result[] "Result"-Array by "<b>SELECT</b>"-queries<br /> |
||
| 1028 | * "boolean" by only "<b>INSERT</b>"-queries<br /> |
||
| 1029 | * "boolean" by only (affected_rows) by "<b>UPDATE / DELETE</b>"-queries<br /> |
||
| 1030 | * "boolean" by only by e.g. "DROP"-queries<br /> |
||
| 1031 | * |
||
| 1032 | * @throws \Exception |
||
| 1033 | */ |
||
| 1034 | 1 | public function multi_query($sql) |
|
| 1096 | |||
| 1097 | /** |
||
| 1098 | * alias: "beginTransaction()" |
||
| 1099 | */ |
||
| 1100 | 1 | public function startTransaction() |
|
| 1104 | |||
| 1105 | /** |
||
| 1106 | * Begins a transaction, by turning off auto commit. |
||
| 1107 | * |
||
| 1108 | * @return boolean this will return true or false indicating success of transaction |
||
| 1109 | */ |
||
| 1110 | 4 | public function beginTransaction() |
|
| 1131 | |||
| 1132 | /** |
||
| 1133 | * Clear the errors in "_debug->_errors". |
||
| 1134 | * |
||
| 1135 | * @return bool |
||
| 1136 | */ |
||
| 1137 | 4 | public function clearErrors() |
|
| 1141 | |||
| 1142 | /** |
||
| 1143 | * Check if we are in a transaction. |
||
| 1144 | * |
||
| 1145 | * @return boolean |
||
| 1146 | */ |
||
| 1147 | 4 | public function inTransaction() |
|
| 1151 | |||
| 1152 | /** |
||
| 1153 | * Ends a transaction and commits if no errors, then ends autocommit. |
||
| 1154 | * |
||
| 1155 | * @return boolean this will return true or false indicating success of transactions |
||
| 1156 | */ |
||
| 1157 | 2 | public function endTransaction() |
|
| 1173 | |||
| 1174 | /** |
||
| 1175 | * Get all errors from "$this->_errors". |
||
| 1176 | * |
||
| 1177 | * @return array|false false === on errors |
||
| 1178 | */ |
||
| 1179 | 2 | public function errors() |
|
| 1185 | |||
| 1186 | /** |
||
| 1187 | * Rollback in a transaction. |
||
| 1188 | */ |
||
| 1189 | 2 | public function rollback() |
|
| 1202 | |||
| 1203 | /** |
||
| 1204 | * Execute a "insert"-query. |
||
| 1205 | * |
||
| 1206 | * @param string $table |
||
| 1207 | * @param array $data |
||
| 1208 | * @param string|null $databaseName <p>use <strong>null</strong> if you will use the current database</p> |
||
| 1209 | * |
||
| 1210 | * @return false|int false on error |
||
| 1211 | */ |
||
| 1212 | 20 | public function insert($table, array $data = array(), $databaseName = null) |
|
| 1239 | |||
| 1240 | /** |
||
| 1241 | * Parses arrays with value pairs and generates SQL to use in queries. |
||
| 1242 | * |
||
| 1243 | * @param array $arrayPair |
||
| 1244 | * @param string $glue this is the separator |
||
| 1245 | * |
||
| 1246 | * @return string |
||
| 1247 | */ |
||
| 1248 | 22 | public function _parseArrayPair($arrayPair, $glue = ',') |
|
| 1394 | |||
| 1395 | /** |
||
| 1396 | * Quote && Escape e.g. a table name string. |
||
| 1397 | * |
||
| 1398 | * @param string $str |
||
| 1399 | * |
||
| 1400 | * @return string |
||
| 1401 | */ |
||
| 1402 | 25 | public function quote_string($str) |
|
| 1415 | |||
| 1416 | /** |
||
| 1417 | * Get errors from "$this->_errors". |
||
| 1418 | * |
||
| 1419 | * @return array |
||
| 1420 | */ |
||
| 1421 | 1 | public function getErrors() |
|
| 1425 | |||
| 1426 | /** |
||
| 1427 | * Execute a "replace"-query. |
||
| 1428 | * |
||
| 1429 | * @param string $table |
||
| 1430 | * @param array $data |
||
| 1431 | * @param null|string $databaseName <p>use <strong>null</strong> if you will use the current database</p> |
||
| 1432 | * |
||
| 1433 | * @return false|int false on error |
||
| 1434 | */ |
||
| 1435 | 1 | public function replace($table, array $data = array(), $databaseName = null) |
|
| 1476 | |||
| 1477 | /** |
||
| 1478 | * Execute a "update"-query. |
||
| 1479 | * |
||
| 1480 | * @param string $table |
||
| 1481 | * @param array $data |
||
| 1482 | * @param array|string $where |
||
| 1483 | * @param null|string $databaseName <p>use <strong>null</strong> if you will use the current database</p> |
||
| 1484 | * |
||
| 1485 | * @return false|int false on error |
||
| 1486 | */ |
||
| 1487 | 6 | public function update($table, array $data = array(), $where = '1=1', $databaseName = null) |
|
| 1522 | |||
| 1523 | /** |
||
| 1524 | * Execute a "delete"-query. |
||
| 1525 | * |
||
| 1526 | * @param string $table |
||
| 1527 | * @param string|array $where |
||
| 1528 | * @param string|null $databaseName <p>use <strong>null</strong> if you will use the current database</p> |
||
| 1529 | * |
||
| 1530 | * @return false|int false on error |
||
| 1531 | */ |
||
| 1532 | 1 | public function delete($table, $where, $databaseName = null) |
|
| 1559 | |||
| 1560 | /** |
||
| 1561 | * Execute a "select"-query. |
||
| 1562 | * |
||
| 1563 | * @param string $table |
||
| 1564 | * @param string|array $where |
||
| 1565 | * @param string|null $databaseName <p>use <strong>null</strong> if you will use the current database</p> |
||
| 1566 | * |
||
| 1567 | * @return false|Result false on error |
||
| 1568 | */ |
||
| 1569 | 20 | public function select($table, $where = '1=1', $databaseName = null) |
|
| 1596 | |||
| 1597 | /** |
||
| 1598 | * Get the last sql-error. |
||
| 1599 | * |
||
| 1600 | * @return string false on error |
||
| 1601 | */ |
||
| 1602 | 1 | public function lastError() |
|
| 1608 | |||
| 1609 | /** |
||
| 1610 | * @return Debug |
||
| 1611 | */ |
||
| 1612 | 9 | public function getDebugger() |
|
| 1616 | |||
| 1617 | /** |
||
| 1618 | * __destruct |
||
| 1619 | * |
||
| 1620 | */ |
||
| 1621 | public function __destruct() |
||
| 1628 | |||
| 1629 | /** |
||
| 1630 | * Closes a previously opened database connection. |
||
| 1631 | */ |
||
| 1632 | 2 | public function close() |
|
| 1640 | |||
| 1641 | /** |
||
| 1642 | * Prevent the instance from being cloned. |
||
| 1643 | * |
||
| 1644 | * @return void |
||
| 1645 | */ |
||
| 1646 | private function __clone() |
||
| 1649 | |||
| 1650 | /** |
||
| 1651 | * __wakeup |
||
| 1652 | * |
||
| 1653 | * @return void |
||
| 1654 | */ |
||
| 1655 | 2 | public function __wakeup() |
|
| 1659 | |||
| 1660 | } |
||
| 1661 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.