PluginProbe ʕ •ᴥ•ʔ
Search Regex / trunk
Search Regex vtrunk
trunk 1.4.12 1.4.13 1.4.14 1.4.15 1.4.16 2.0 2.0.1 2.1 2.2 2.2.1 2.3 2.3.1 2.3.2 2.3.3 2.4 2.4.1 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.1 3.1.1 3.1.2 3.2 3.3 3.3.0 3.3.1 3.4 3.4.1 3.4.2
search-regex / includes / sql / modifier / class-select-count-id.php
search-regex / includes / sql / modifier Last commit date
class-modifier.php 5 months ago class-select-count-id.php 5 months ago
class-select-count-id.php
37 lines
1 <?php
2
3 namespace SearchRegex\Sql\Modifier;
4
5 use SearchRegex\Sql;
6
7 /**
8 * Perform a COUNT of a query
9 */
10 class Select_Count_Id extends Modifier {
11 /**
12 * Column to modify
13 *
14 * @readonly
15 */
16 private string $column;
17
18 /**
19 * Constructor
20 *
21 * @param Sql\Value $table Table name.
22 * @param Sql\Value $table_id Table ID.
23 * @param string $alias Count alias.
24 */
25 public function __construct( Sql\Value $table, Sql\Value $table_id, $alias = 'match_rows' ) {
26 $this->column = 'COUNT(' . $table->get_value() . '.' . $table_id->get_value() . ") AS $alias";
27 }
28
29 public function get_select( array $select, array $joins ) {
30 return [ $this->column ];
31 }
32
33 public function get_group( array $group, array $joins ) {
34 return [];
35 }
36 }
37