PluginProbe ʕ •ᴥ•ʔ
Search Regex / 3.4
Search Regex v3.4
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 / where / class-where-in.php
search-regex / includes / sql / where Last commit date
class-where-and.php 5 months ago class-where-date.php 5 months ago class-where-in.php 5 months ago class-where-integer.php 5 months ago class-where-null.php 5 months ago class-where-or.php 5 months ago class-where-string.php 5 months ago class-where.php 5 months ago
class-where-in.php
48 lines
1 <?php
2
3 namespace SearchRegex\Sql\Where;
4
5 use SearchRegex\Sql;
6
7 /**
8 * WHERE for a IN
9 */
10 class Where_In extends Where {
11 /**
12 * Constructor
13 *
14 * @param Sql\Select\Select $column Column.
15 * @param string $logic Logic.
16 * @param list<string|int> $value Value.
17 */
18 public function __construct( Sql\Select\Select $column, $logic, $value ) {
19 $logic_sql = 'IN';
20
21 if ( $logic === 'NOT IN' ) {
22 $logic_sql = 'NOT IN';
23 }
24
25 parent::__construct( $column, $logic_sql, $value );
26 }
27
28 public function get_value() {
29 global $wpdb;
30
31 if ( ! is_array( $this->value ) ) {
32 return '';
33 }
34
35 $values = array_map(
36 function ( $item ) use ( $wpdb ) {
37 if ( is_numeric( $item ) ) {
38 return $wpdb->prepare( '%d', $item );
39 }
40
41 return $wpdb->prepare( '%s', $item );
42 }, $this->value
43 );
44
45 return '(' . implode( ', ', $values ) . ')';
46 }
47 }
48