Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
operator.php
1<?php
11
18{
23 protected static $operators = array(
24 '=' => 'eq',
25 '<>' => 'neq',
26 '!=' => 'neq',
27 '<' => 'lt',
28 '<=' => 'lte',
29 '>' => 'gt',
30 '>=' => 'gte',
31 'in' => 'in',
32 'between' => 'between',
33 'like' => 'like',
34 'exists' => 'exists',
35 'match' => 'match',
36 'expr' => 'expr'
37 );
38
44 public static function get()
45 {
46 return static::$operators;
47 }
48
49 public static function eq($columnSql, $valueSql)
50 {
51 if ($valueSql instanceof NullExpression)
52 {
53 return "{$columnSql} IS NULL";
54 }
55 return "{$columnSql} = {$valueSql}";
56 }
57
58 public static function neq($columnSql, $valueSql)
59 {
60 if ($valueSql instanceof NullExpression)
61 {
62 return "{$columnSql} IS NOT NULL";
63 }
64 return "{$columnSql} <> {$valueSql}";
65 }
66
67 public static function lt($columnSql, $valueSql)
68 {
69 return "{$columnSql} < {$valueSql}";
70 }
71
72 public static function lte($columnSql, $valueSql)
73 {
74 return "{$columnSql} <= {$valueSql}";
75 }
76
77 public static function gt($columnSql, $valueSql)
78 {
79 return "{$columnSql} > {$valueSql}";
80 }
81
82 public static function gte($columnSql, $valueSql)
83 {
84 return "{$columnSql} >= {$valueSql}";
85 }
86
87 public static function in($columnSql, $valueSql)
88 {
89 return "{$columnSql} IN (".join(', ', (array) $valueSql).")";
90 }
91
92 public static function between($columnSql, $valueSql)
93 {
94 return "{$columnSql} BETWEEN {$valueSql[0]} AND {$valueSql[1]}";
95 }
96
97 public static function like($columnSql, $valueSql)
98 {
99 return "{$columnSql} LIKE {$valueSql}";
100 }
101
102 public static function exists($columnSql, $valueSql)
103 {
104 return "EXISTS ({$valueSql})";
105 }
106
107 public static function match($columnSql, $valueSql)
108 {
109 $connection = \Bitrix\Main\Application::getConnection();
110 $helper = $connection->getSqlHelper();
111
112 return $helper->getMatchFunction($columnSql, $valueSql);
113 }
114
115 public static function expr($columnSql, $valueSql)
116 {
117 return "{$columnSql}";
118 }
119}
static lt($columnSql, $valueSql)
Definition operator.php:67
static eq($columnSql, $valueSql)
Definition operator.php:49
static gte($columnSql, $valueSql)
Definition operator.php:82
static match($columnSql, $valueSql)
Definition operator.php:107
static between($columnSql, $valueSql)
Definition operator.php:92
static in($columnSql, $valueSql)
Definition operator.php:87
static exists($columnSql, $valueSql)
Definition operator.php:102
static expr($columnSql, $valueSql)
Definition operator.php:115
static lte($columnSql, $valueSql)
Definition operator.php:72
static gt($columnSql, $valueSql)
Definition operator.php:77
static neq($columnSql, $valueSql)
Definition operator.php:58
static like($columnSql, $valueSql)
Definition operator.php:97