PluginProbe ʕ •ᴥ•ʔ
Rank Math SEO – AI SEO Tools to Dominate SEO Rankings / 1.0.239
Rank Math SEO – AI SEO Tools to Dominate SEO Rankings v1.0.239
1.0.273 1.0.272 1.0.271 1.0.271.1 1.0.270 1.0.269 trunk 1.0.216 1.0.217 1.0.218 1.0.219 1.0.220 1.0.221 1.0.222 1.0.223 1.0.224 1.0.225 1.0.226 1.0.227 1.0.227.1 1.0.228 1.0.229 1.0.230 1.0.231 1.0.232 1.0.233 1.0.234 1.0.234.1 1.0.235 1.0.236 1.0.237 1.0.238 1.0.239 1.0.240 1.0.241 1.0.242 1.0.243 1.0.244 1.0.245 1.0.246 1.0.247 1.0.248 1.0.249 1.0.250 1.0.251 1.0.251.1 1.0.252 1.0.252.1 1.0.253 1.0.254 1.0.255 1.0.256 1.0.257 1.0.258 1.0.259 1.0.259.1 1.0.260 1.0.261 1.0.262 1.0.263 1.0.264 1.0.264.1 1.0.265 1.0.266 1.0.266.1 1.0.267 1.0.268
seo-by-rank-math / vendor / mythemeshop / wordpress-helpers / src / database / class-select.php
seo-by-rank-math / vendor / mythemeshop / wordpress-helpers / src / database Last commit date
class-clauses.php 2 years ago class-database.php 2 years ago class-escape.php 2 years ago class-groupby.php 2 years ago class-joins.php 2 years ago class-orderby.php 2 years ago class-query-builder.php 2 years ago class-select.php 2 years ago class-translate.php 2 years ago class-where.php 2 years ago index.php 2 years ago
class-select.php
132 lines
1 <?php
2 /**
3 * The select functions.
4 *
5 * @since 1.0.0
6 * @package MyThemeShop
7 * @subpackage MyThemeShop\Database
8 * @author MyThemeShop <admin@mythemeshop.com>
9 */
10
11 namespace MyThemeShop\Database;
12
13 /**
14 * Select class.
15 */
16 trait Select {
17
18 /**
19 * Set the selected fields
20 *
21 * @param array $fields Fields to select.
22 *
23 * @return self The current query builder.
24 */
25 public function select( $fields = '' ) {
26 if ( empty( $fields ) ) {
27 return $this;
28 }
29
30 if ( is_string( $fields ) ) {
31 $this->add_sql_clause( 'select', $fields );
32 return $this;
33 }
34
35 foreach ( $fields as $key => $field ) {
36 $this->add_sql_clause( 'select', is_string( $key ) ? "$key AS $field" : $field );
37 }
38
39 return $this;
40 }
41
42 /**
43 * Shortcut to add a count function
44 *
45 * ->selectCount('id')
46 * ->selectCount('id', 'count')
47 *
48 * @param string $field Column name.
49 * @param string $alias (Optional) Column alias.
50 *
51 * @return self The current query builder.
52 */
53 public function selectCount( $field = '*', $alias = null ) { // @codingStandardsIgnoreLine
54 return $this->selectFunc( 'count', $field, $alias );
55 }
56
57 /**
58 * Shortcut to add a sum function
59 *
60 * ->selectSum('id')
61 * ->selectSum('id', 'total')
62 *
63 * @param string $field Column name.
64 * @param string $alias (Optional) Column alias.
65 *
66 * @return self The current query builder.
67 */
68 public function selectSum( $field, $alias = null ) { // @codingStandardsIgnoreLine
69 return $this->selectFunc( 'sum', $field, $alias );
70 }
71
72 /**
73 * Shortcut to add a avg function
74 *
75 * ->selectAvg('id')
76 * ->selectAvg('id', 'average')
77 *
78 * @param string $field Column name.
79 * @param string $alias (Optional) Column alias.
80 *
81 * @return self The current query builder.
82 */
83 public function selectAvg( $field, $alias = null ) { // @codingStandardsIgnoreLine
84 return $this->selectFunc( 'avg', $field, $alias );
85 }
86
87 /**
88 * Shortcut to add a function
89 *
90 * @param string $func Function name.
91 * @param string $field Column name.
92 * @param string $alias (Optional) Column alias.
93 *
94 * @return self The current query builder.
95 */
96 public function selectFunc( $func, $field, $alias = null ) { // @codingStandardsIgnoreLine
97 $func = \strtoupper( $func );
98 $field = "$func({$field})";
99 if ( ! is_null( $alias ) ) {
100 $field .= " AS {$alias}";
101 }
102
103 $this->add_sql_clause( 'select', $field );
104
105 return $this;
106 }
107
108 /**
109 * Distinct select setter
110 *
111 * @param bool $distinct Is disticnt.
112 *
113 * @return self The current query builder.
114 */
115 public function distinct( $distinct = true ) {
116 $this->distinct = $distinct;
117 return $this;
118 }
119
120 /**
121 * SQL_CALC_FOUND_ROWS select setter
122 *
123 * @param bool $found_rows Should get found rows.
124 *
125 * @return self The current query builder.
126 */
127 public function found_rows( $found_rows = true ) {
128 $this->found_rows = $found_rows;
129 return $this;
130 }
131 }
132