Complex classes like Select 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 Select, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 21 | class Select extends AbstractQuery implements SelectInterface, SubselectInterface |
||
| 22 | { |
||
| 23 | /** |
||
| 24 | * |
||
| 25 | * An array of union SELECT statements. |
||
| 26 | * |
||
| 27 | * @var array |
||
| 28 | * |
||
| 29 | */ |
||
| 30 | protected $union = array(); |
||
| 31 | |||
| 32 | /** |
||
| 33 | * |
||
| 34 | * Is this a SELECT FOR UPDATE? |
||
| 35 | * |
||
| 36 | * @var |
||
| 37 | * |
||
| 38 | */ |
||
| 39 | protected $for_update = false; |
||
| 40 | |||
| 41 | /** |
||
| 42 | * |
||
| 43 | * The columns to be selected. |
||
| 44 | * |
||
| 45 | * @var array |
||
| 46 | * |
||
| 47 | */ |
||
| 48 | protected $cols = array(); |
||
| 49 | |||
| 50 | /** |
||
| 51 | * |
||
| 52 | * Select from these tables; includes JOIN clauses. |
||
| 53 | * |
||
| 54 | * @var array |
||
| 55 | * |
||
| 56 | */ |
||
| 57 | protected $from = array(); |
||
| 58 | |||
| 59 | /** |
||
| 60 | * |
||
| 61 | * The current key in the `$from` array. |
||
| 62 | * |
||
| 63 | * @var int |
||
| 64 | * |
||
| 65 | */ |
||
| 66 | protected $from_key = -1; |
||
| 67 | |||
| 68 | /** |
||
| 69 | * |
||
| 70 | * Tracks which JOIN clauses are attached to which FROM tables. |
||
| 71 | * |
||
| 72 | * @var array |
||
| 73 | * |
||
| 74 | */ |
||
| 75 | protected $join = array(); |
||
| 76 | |||
| 77 | /** |
||
| 78 | * |
||
| 79 | * GROUP BY these columns. |
||
| 80 | * |
||
| 81 | * @var array |
||
| 82 | * |
||
| 83 | */ |
||
| 84 | protected $group_by = array(); |
||
| 85 | |||
| 86 | /** |
||
| 87 | * |
||
| 88 | * The list of HAVING conditions. |
||
| 89 | * |
||
| 90 | * @var array |
||
| 91 | * |
||
| 92 | */ |
||
| 93 | protected $having = array(); |
||
| 94 | |||
| 95 | /** |
||
| 96 | * |
||
| 97 | * The page number to select. |
||
| 98 | * |
||
| 99 | * @var int |
||
| 100 | * |
||
| 101 | */ |
||
| 102 | protected $page = 0; |
||
| 103 | |||
| 104 | /** |
||
| 105 | * |
||
| 106 | * The number of rows per page. |
||
| 107 | * |
||
| 108 | * @var int |
||
| 109 | * |
||
| 110 | */ |
||
| 111 | protected $paging = 10; |
||
| 112 | |||
| 113 | /** |
||
| 114 | * |
||
| 115 | * Tracks table references to avoid duplicate identifiers. |
||
| 116 | * |
||
| 117 | * @var array |
||
| 118 | * |
||
| 119 | */ |
||
| 120 | protected $table_refs = array(); |
||
| 121 | |||
| 122 | /** |
||
| 123 | * |
||
| 124 | * Returns this query object as an SQL statement string. |
||
| 125 | * |
||
| 126 | * @return string An SQL statement string. |
||
| 127 | * |
||
| 128 | */ |
||
| 129 | 184 | public function getStatement() |
|
| 137 | |||
| 138 | /** |
||
| 139 | * |
||
| 140 | * Sets the number of rows per page. |
||
| 141 | * |
||
| 142 | * @param int $paging The number of rows to page at. |
||
| 143 | * |
||
| 144 | * @return $this |
||
| 145 | * |
||
| 146 | */ |
||
| 147 | 10 | public function setPaging($paging) |
|
| 148 | { |
||
| 149 | 10 | $this->paging = (int) $paging; |
|
| 150 | 10 | if ($this->page) { |
|
| 151 | 5 | $this->setPagingLimitOffset(); |
|
| 152 | 5 | } |
|
| 153 | 10 | return $this; |
|
| 154 | } |
||
| 155 | |||
| 156 | /** |
||
| 157 | * |
||
| 158 | * Gets the number of rows per page. |
||
| 159 | * |
||
| 160 | * @return int The number of rows per page. |
||
| 161 | * |
||
| 162 | */ |
||
| 163 | 10 | public function getPaging() |
|
| 167 | |||
| 168 | /** |
||
| 169 | * |
||
| 170 | * Makes the select FOR UPDATE (or not). |
||
| 171 | * |
||
| 172 | * @param bool $enable Whether or not the SELECT is FOR UPDATE (default |
||
| 173 | * true). |
||
| 174 | * |
||
| 175 | * @return $this |
||
| 176 | * |
||
| 177 | */ |
||
| 178 | 20 | public function forUpdate($enable = true) |
|
| 183 | |||
| 184 | /** |
||
| 185 | * |
||
| 186 | * Makes the select DISTINCT (or not). |
||
| 187 | * |
||
| 188 | * @param bool $enable Whether or not the SELECT is DISTINCT (default |
||
| 189 | * true). |
||
| 190 | * |
||
| 191 | * @return $this |
||
| 192 | * |
||
| 193 | */ |
||
| 194 | 16 | public function distinct($enable = true) |
|
| 199 | |||
| 200 | /** |
||
| 201 | * |
||
| 202 | * Is the select DISTINCT? |
||
| 203 | * |
||
| 204 | * @return bool |
||
| 205 | * |
||
| 206 | */ |
||
| 207 | 10 | public function isDistinct() |
|
| 211 | |||
| 212 | /** |
||
| 213 | * |
||
| 214 | * Adds columns to the query. |
||
| 215 | * |
||
| 216 | * Multiple calls to cols() will append to the list of columns, not |
||
| 217 | * overwrite the previous columns. |
||
| 218 | * |
||
| 219 | * @param array $cols The column(s) to add to the query. The elements can be |
||
| 220 | * any mix of these: `array("col", "col AS alias", "col" => "alias")` |
||
| 221 | * |
||
| 222 | * @return $this |
||
| 223 | * |
||
| 224 | */ |
||
| 225 | 224 | public function cols(array $cols) |
|
| 232 | |||
| 233 | /** |
||
| 234 | * |
||
| 235 | * Adds a column and alias to the columns to be selected. |
||
| 236 | * |
||
| 237 | * @param mixed $key If an integer, ignored. Otherwise, the column to be |
||
| 238 | * added. |
||
| 239 | * |
||
| 240 | * @param mixed $val If $key was an integer, the column to be added; |
||
| 241 | * otherwise, the column alias. |
||
| 242 | * |
||
| 243 | * @return null |
||
| 244 | * |
||
| 245 | */ |
||
| 246 | 224 | protected function addCol($key, $val) |
|
| 255 | |||
| 256 | /** |
||
| 257 | * |
||
| 258 | * Adds a column with an alias to the columns to be selected. |
||
| 259 | * |
||
| 260 | * @param string $spec The column specification: "col alias", |
||
| 261 | * "col AS alias", or something else entirely. |
||
| 262 | * |
||
| 263 | * @return null |
||
| 264 | * |
||
| 265 | */ |
||
| 266 | 214 | protected function addColWithAlias($spec) |
|
| 281 | |||
| 282 | /** |
||
| 283 | * |
||
| 284 | * Remove a column via its alias. |
||
| 285 | * |
||
| 286 | * @param string $alias The column to remove |
||
| 287 | * |
||
| 288 | * @return null |
||
| 289 | * |
||
| 290 | */ |
||
| 291 | 15 | public function removeCol($alias) |
|
| 307 | |||
| 308 | /** |
||
| 309 | * |
||
| 310 | * Does the query have any columns in it? |
||
| 311 | * |
||
| 312 | * @return bool |
||
| 313 | * |
||
| 314 | */ |
||
| 315 | 5 | public function hasCols() |
|
| 319 | |||
| 320 | /** |
||
| 321 | * |
||
| 322 | * Returns a list of columns. |
||
| 323 | * |
||
| 324 | * @return array |
||
| 325 | * |
||
| 326 | */ |
||
| 327 | 15 | public function getCols() |
|
| 331 | |||
| 332 | /** |
||
| 333 | * |
||
| 334 | * Tracks table references. |
||
| 335 | * |
||
| 336 | * @param string $type FROM, JOIN, etc. |
||
| 337 | * |
||
| 338 | * @param string $spec The table and alias name. |
||
| 339 | * |
||
| 340 | * @return null |
||
| 341 | * |
||
| 342 | * @throws Exception when the reference has already been used. |
||
| 343 | * |
||
| 344 | */ |
||
| 345 | 149 | protected function addTableRef($type, $spec) |
|
| 361 | |||
| 362 | /** |
||
| 363 | * |
||
| 364 | * Adds a FROM element to the query; quotes the table name automatically. |
||
| 365 | * |
||
| 366 | * @param string $spec The table specification; "foo" or "foo AS bar". |
||
| 367 | * |
||
| 368 | * @return $this |
||
| 369 | * |
||
| 370 | */ |
||
| 371 | 139 | public function from($spec) |
|
| 376 | |||
| 377 | /** |
||
| 378 | * |
||
| 379 | * Adds a raw unquoted FROM element to the query; useful for adding FROM |
||
| 380 | * elements that are functions. |
||
| 381 | * |
||
| 382 | * @param string $spec The table specification, e.g. "function_name()". |
||
| 383 | * |
||
| 384 | * @return $this |
||
| 385 | * |
||
| 386 | */ |
||
| 387 | 5 | public function fromRaw($spec) |
|
| 392 | |||
| 393 | /** |
||
| 394 | * |
||
| 395 | * Adds to the $from property and increments the key count. |
||
| 396 | * |
||
| 397 | * @param string $spec The table specification. |
||
| 398 | * |
||
| 399 | * @return $this |
||
| 400 | * |
||
| 401 | */ |
||
| 402 | 149 | protected function addFrom($spec) |
|
| 408 | |||
| 409 | /** |
||
| 410 | * |
||
| 411 | * Adds an aliased sub-select to the query. |
||
| 412 | * |
||
| 413 | * @param string|Select $spec If a Select object, use as the sub-select; |
||
| 414 | * if a string, the sub-select string. |
||
| 415 | * |
||
| 416 | * @param string $name The alias name for the sub-select. |
||
| 417 | * |
||
| 418 | * @return $this |
||
| 419 | * |
||
| 420 | */ |
||
| 421 | 15 | public function fromSubSelect($spec, $name) |
|
| 428 | |||
| 429 | /** |
||
| 430 | * |
||
| 431 | * Formats a sub-SELECT statement, binding values from a Select object as |
||
| 432 | * needed. |
||
| 433 | * |
||
| 434 | * @param string|SelectInterface $spec A sub-SELECT specification. |
||
| 435 | * |
||
| 436 | * @param string $indent Indent each line with this string. |
||
| 437 | * |
||
| 438 | * @return string The sub-SELECT string. |
||
| 439 | * |
||
| 440 | */ |
||
| 441 | 25 | protected function subSelect($spec, $indent) |
|
| 451 | |||
| 452 | /** |
||
| 453 | * |
||
| 454 | * Adds a JOIN table and columns to the query. |
||
| 455 | * |
||
| 456 | * @param string $join The join type: inner, left, natural, etc. |
||
| 457 | * |
||
| 458 | * @param string $spec The table specification; "foo" or "foo AS bar". |
||
| 459 | * |
||
| 460 | * @param string $cond Join on this condition. |
||
| 461 | * |
||
| 462 | * @param array $bind Values to bind to ?-placeholders in the condition. |
||
| 463 | * |
||
| 464 | * @return $this |
||
| 465 | * |
||
| 466 | * @throws Exception |
||
| 467 | * |
||
| 468 | */ |
||
| 469 | 45 | public function join($join, $spec, $cond = null, array $bind = array()) |
|
| 478 | |||
| 479 | /** |
||
| 480 | * |
||
| 481 | * Fixes a JOIN condition to quote names in the condition and prefix it |
||
| 482 | * with a condition type ('ON' is the default and 'USING' is recognized). |
||
| 483 | * |
||
| 484 | * @param string $cond Join on this condition. |
||
| 485 | * |
||
| 486 | * @param array $bind Values to bind to ?-placeholders in the condition. |
||
| 487 | * |
||
| 488 | * @return string |
||
| 489 | * |
||
| 490 | */ |
||
| 491 | 55 | protected function fixJoinCondition($cond, array $bind) |
|
| 510 | |||
| 511 | /** |
||
| 512 | * |
||
| 513 | * Adds a INNER JOIN table and columns to the query. |
||
| 514 | * |
||
| 515 | * @param string $spec The table specification; "foo" or "foo AS bar". |
||
| 516 | * |
||
| 517 | * @param string $cond Join on this condition. |
||
| 518 | * |
||
| 519 | * @param array $bind Values to bind to ?-placeholders in the condition. |
||
| 520 | * |
||
| 521 | * @return $this |
||
| 522 | * |
||
| 523 | * @throws Exception |
||
| 524 | * |
||
| 525 | */ |
||
| 526 | 10 | public function innerJoin($spec, $cond = null, array $bind = array()) |
|
| 530 | |||
| 531 | /** |
||
| 532 | * |
||
| 533 | * Adds a LEFT JOIN table and columns to the query. |
||
| 534 | * |
||
| 535 | * @param string $spec The table specification; "foo" or "foo AS bar". |
||
| 536 | * |
||
| 537 | * @param string $cond Join on this condition. |
||
| 538 | * |
||
| 539 | * @param array $bind Values to bind to ?-placeholders in the condition. |
||
| 540 | * |
||
| 541 | * @return $this |
||
| 542 | * |
||
| 543 | * @throws Exception |
||
| 544 | * |
||
| 545 | */ |
||
| 546 | 10 | public function leftJoin($spec, $cond = null, array $bind = array()) |
|
| 550 | |||
| 551 | /** |
||
| 552 | * |
||
| 553 | * Adds a JOIN to an aliased subselect and columns to the query. |
||
| 554 | * |
||
| 555 | * @param string $join The join type: inner, left, natural, etc. |
||
| 556 | * |
||
| 557 | * @param string|Select $spec If a Select |
||
| 558 | * object, use as the sub-select; if a string, the sub-select |
||
| 559 | * command string. |
||
| 560 | * |
||
| 561 | * @param string $name The alias name for the sub-select. |
||
| 562 | * |
||
| 563 | * @param string $cond Join on this condition. |
||
| 564 | * |
||
| 565 | * @param array $bind Values to bind to ?-placeholders in the condition. |
||
| 566 | * |
||
| 567 | * @return $this |
||
| 568 | * |
||
| 569 | * @throws Exception |
||
| 570 | * |
||
| 571 | */ |
||
| 572 | 20 | public function joinSubSelect($join, $spec, $name, $cond = null, array $bind = array()) |
|
| 584 | |||
| 585 | /** |
||
| 586 | * |
||
| 587 | * Adds the JOIN to the right place, given whether or not a FROM has been |
||
| 588 | * specified yet. |
||
| 589 | * |
||
| 590 | * @param string $spec The JOIN clause. |
||
| 591 | * |
||
| 592 | * @return $this |
||
| 593 | * |
||
| 594 | */ |
||
| 595 | 55 | protected function addJoin($spec) |
|
| 601 | |||
| 602 | /** |
||
| 603 | * |
||
| 604 | * Adds grouping to the query. |
||
| 605 | * |
||
| 606 | * @param array $spec The column(s) to group by. |
||
| 607 | * |
||
| 608 | * @return $this |
||
| 609 | * |
||
| 610 | */ |
||
| 611 | 5 | public function groupBy(array $spec) |
|
| 618 | |||
| 619 | /** |
||
| 620 | * |
||
| 621 | * Adds a HAVING condition to the query by AND. If the condition has |
||
| 622 | * ?-placeholders, additional arguments to the method will be bound to |
||
| 623 | * those placeholders sequentially. |
||
| 624 | * |
||
| 625 | * @param string $cond The HAVING condition. |
||
| 626 | * |
||
| 627 | * @return $this |
||
| 628 | * |
||
| 629 | */ |
||
| 630 | 10 | public function having($cond) |
|
| 635 | |||
| 636 | /** |
||
| 637 | * |
||
| 638 | * Adds a HAVING condition to the query by AND. If the condition has |
||
| 639 | * ?-placeholders, additional arguments to the method will be bound to |
||
| 640 | * those placeholders sequentially. |
||
| 641 | * |
||
| 642 | * @param string $cond The HAVING condition. |
||
| 643 | * |
||
| 644 | * @return $this |
||
| 645 | * |
||
| 646 | * @see having() |
||
| 647 | * |
||
| 648 | */ |
||
| 649 | 5 | public function orHaving($cond) |
|
| 654 | |||
| 655 | /** |
||
| 656 | * |
||
| 657 | * Sets the limit and count by page number. |
||
| 658 | * |
||
| 659 | * @param int $page Limit results to this page number. |
||
| 660 | * |
||
| 661 | * @return $this |
||
| 662 | * |
||
| 663 | */ |
||
| 664 | 25 | public function page($page) |
|
| 670 | |||
| 671 | /** |
||
| 672 | * |
||
| 673 | * Updates the limit and offset values when changing pagination. |
||
| 674 | * |
||
| 675 | * @return null |
||
| 676 | * |
||
| 677 | */ |
||
| 678 | 25 | protected function setPagingLimitOffset() |
|
| 687 | |||
| 688 | /** |
||
| 689 | * |
||
| 690 | * Returns the page number being selected. |
||
| 691 | * |
||
| 692 | * @return int |
||
| 693 | * |
||
| 694 | */ |
||
| 695 | 5 | public function getPage() |
|
| 699 | |||
| 700 | /** |
||
| 701 | * |
||
| 702 | * Takes the current select properties and retains them, then sets |
||
| 703 | * UNION for the next set of properties. |
||
| 704 | * |
||
| 705 | * @return $this |
||
| 706 | * |
||
| 707 | */ |
||
| 708 | 10 | public function union() |
|
| 714 | |||
| 715 | /** |
||
| 716 | * |
||
| 717 | * Takes the current select properties and retains them, then sets |
||
| 718 | * UNION ALL for the next set of properties. |
||
| 719 | * |
||
| 720 | * @return $this |
||
| 721 | * |
||
| 722 | */ |
||
| 723 | 5 | public function unionAll() |
|
| 729 | |||
| 730 | /** |
||
| 731 | * |
||
| 732 | * Returns the LIMIT value. |
||
| 733 | * |
||
| 734 | * @return int |
||
| 735 | * |
||
| 736 | */ |
||
| 737 | 10 | public function getLimit() |
|
| 741 | |||
| 742 | /** |
||
| 743 | * |
||
| 744 | * Returns the OFFSET value. |
||
| 745 | * |
||
| 746 | * @return int |
||
| 747 | * |
||
| 748 | */ |
||
| 749 | 10 | public function getOffset() |
|
| 753 | |||
| 754 | /** |
||
| 755 | * |
||
| 756 | * Clears the current select properties; generally used after adding a |
||
| 757 | * union. |
||
| 758 | * |
||
| 759 | * @return null |
||
| 760 | * |
||
| 761 | */ |
||
| 762 | 15 | public function reset() |
|
| 776 | |||
| 777 | /** |
||
| 778 | * |
||
| 779 | * Resets the columns on the SELECT. |
||
| 780 | * |
||
| 781 | * @return $this |
||
| 782 | * |
||
| 783 | */ |
||
| 784 | 15 | public function resetCols() |
|
| 789 | |||
| 790 | /** |
||
| 791 | * |
||
| 792 | * Resets the FROM and JOIN clauses on the SELECT. |
||
| 793 | * |
||
| 794 | * @return $this |
||
| 795 | * |
||
| 796 | */ |
||
| 797 | 15 | public function resetTables() |
|
| 805 | |||
| 806 | /** |
||
| 807 | * |
||
| 808 | * Resets the WHERE clause on the SELECT. |
||
| 809 | * |
||
| 810 | * @return $this |
||
| 811 | * |
||
| 812 | */ |
||
| 813 | 15 | public function resetWhere() |
|
| 818 | |||
| 819 | /** |
||
| 820 | * |
||
| 821 | * Resets the GROUP BY clause on the SELECT. |
||
| 822 | * |
||
| 823 | * @return $this |
||
| 824 | * |
||
| 825 | */ |
||
| 826 | 15 | public function resetGroupBy() |
|
| 831 | |||
| 832 | /** |
||
| 833 | * |
||
| 834 | * Resets the HAVING clause on the SELECT. |
||
| 835 | * |
||
| 836 | * @return $this |
||
| 837 | * |
||
| 838 | */ |
||
| 839 | 15 | public function resetHaving() |
|
| 844 | |||
| 845 | /** |
||
| 846 | * |
||
| 847 | * Resets the ORDER BY clause on the SELECT. |
||
| 848 | * |
||
| 849 | * @return $this |
||
| 850 | * |
||
| 851 | */ |
||
| 852 | 15 | public function resetOrderBy() |
|
| 857 | |||
| 858 | /** |
||
| 859 | * |
||
| 860 | * Resets the UNION and UNION ALL clauses on the SELECT. |
||
| 861 | * |
||
| 862 | * @return $this |
||
| 863 | * |
||
| 864 | */ |
||
| 865 | public function resetUnions() |
||
| 870 | |||
| 871 | /** |
||
| 872 | * |
||
| 873 | * Builds this query object into a string. |
||
| 874 | * |
||
| 875 | * @return string |
||
| 876 | * |
||
| 877 | */ |
||
| 878 | 184 | protected function build() |
|
| 891 | |||
| 892 | /** |
||
| 893 | * |
||
| 894 | * Builds the columns clause. |
||
| 895 | * |
||
| 896 | * @return string |
||
| 897 | * |
||
| 898 | * @throws Exception when there are no columns in the SELECT. |
||
| 899 | * |
||
| 900 | */ |
||
| 901 | 184 | protected function buildCols() |
|
| 918 | |||
| 919 | /** |
||
| 920 | * |
||
| 921 | * Builds the FROM clause. |
||
| 922 | * |
||
| 923 | * @return string |
||
| 924 | * |
||
| 925 | */ |
||
| 926 | 179 | protected function buildFrom() |
|
| 941 | |||
| 942 | /** |
||
| 943 | * |
||
| 944 | * Builds the GROUP BY clause. |
||
| 945 | * |
||
| 946 | * @return string |
||
| 947 | * |
||
| 948 | */ |
||
| 949 | 179 | protected function buildGroupBy() |
|
| 957 | |||
| 958 | /** |
||
| 959 | * |
||
| 960 | * Builds the HAVING clause. |
||
| 961 | * |
||
| 962 | * @return string |
||
| 963 | * |
||
| 964 | */ |
||
| 965 | 179 | protected function buildHaving() |
|
| 973 | |||
| 974 | /** |
||
| 975 | * |
||
| 976 | * Builds the FOR UPDATE clause. |
||
| 977 | * |
||
| 978 | * @return string |
||
| 979 | * |
||
| 980 | */ |
||
| 981 | 179 | protected function buildForUpdate() |
|
| 989 | |||
| 990 | /** |
||
| 991 | * |
||
| 992 | * Adds a WHERE condition to the query by AND. If the condition has |
||
| 993 | * ?-placeholders, additional arguments to the method will be bound to |
||
| 994 | * those placeholders sequentially. |
||
| 995 | * |
||
| 996 | * @param string $cond The WHERE condition. |
||
| 997 | * @param mixed ...$bind arguments to bind to placeholders |
||
| 998 | * |
||
| 999 | * @return $this |
||
| 1000 | * |
||
| 1001 | */ |
||
| 1002 | 30 | public function where($cond) |
|
| 1007 | |||
| 1008 | /** |
||
| 1009 | * |
||
| 1010 | * Adds a WHERE condition to the query by OR. If the condition has |
||
| 1011 | * ?-placeholders, additional arguments to the method will be bound to |
||
| 1012 | * those placeholders sequentially. |
||
| 1013 | * |
||
| 1014 | * @param string $cond The WHERE condition. |
||
| 1015 | * @param mixed ...$bind arguments to bind to placeholders |
||
| 1016 | * |
||
| 1017 | * @return $this |
||
| 1018 | * |
||
| 1019 | * @see where() |
||
| 1020 | * |
||
| 1021 | */ |
||
| 1022 | 5 | public function orWhere($cond) |
|
| 1027 | |||
| 1028 | /** |
||
| 1029 | * |
||
| 1030 | * Sets a limit count on the query. |
||
| 1031 | * |
||
| 1032 | * @param int $limit The number of rows to select. |
||
| 1033 | * |
||
| 1034 | * @return $this |
||
| 1035 | * |
||
| 1036 | */ |
||
| 1037 | 30 | public function limit($limit) |
|
| 1046 | |||
| 1047 | /** |
||
| 1048 | * |
||
| 1049 | * Sets a limit offset on the query. |
||
| 1050 | * |
||
| 1051 | * @param int $offset Start returning after this many rows. |
||
| 1052 | * |
||
| 1053 | * @return $this |
||
| 1054 | * |
||
| 1055 | */ |
||
| 1056 | 30 | public function offset($offset) |
|
| 1065 | |||
| 1066 | /** |
||
| 1067 | * |
||
| 1068 | * Adds a column order to the query. |
||
| 1069 | * |
||
| 1070 | * @param array $spec The columns and direction to order by. |
||
| 1071 | * |
||
| 1072 | * @return $this |
||
| 1073 | * |
||
| 1074 | */ |
||
| 1075 | 5 | public function orderBy(array $spec) |
|
| 1079 | } |
||
| 1080 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.