PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 2.15.3
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v2.15.3
3.3.1 V-3.3.0 3.2.2 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 V3.0.3 V3.0.2 -3.0.1 V_3.0.0 1.1.1 1.1.8 1.2 1.3 1.4 1.4.18 1.5.2 1.9 2.0 2.10.0 2.10.1 All 138 releases
← All changes | includes/Core/Database/Helper.php +146 -142 1.92.15.3 View file →
@@ -1,169 +1,173 @@
1 1 <?php
2 +
2 3 namespace BitCode\BitForm\Core\Database;
3 4
4 -final class Helper {
5 - // public static function getTableName($className)
6 - // {
7 - // $className = str_replace('\\', '', $className);
8 - // $className = str_replace('Model', '', $className);
9 - // return strtolower($className);
10 - // }
11 - public function arrValueModifyByLogic( $operator, $value ) {
12 - $oprators = [
13 - 'equal' => '["' . implode( '","', $value ) . '"]',
14 - 'not_equal' => '["' . implode( '","', $value ) . '"]',
15 - 'start_with' => '["' . implode( '","', $value ) . '"%',
16 - 'not_start_with' => '["' . implode( '","', $value ) . '"%',
17 - 'end_with' => '%"' . implode( '","', $value ) . '"]',
18 - 'not_end_with' => '%"' . implode( '","', $value ) . '"]',
19 - 'contain' => '%"' . implode( '","', $value ) . '"%',
20 - 'not_contain' => '%"' . implode( '","', $value ) . '"%',
21 - 'empty' => '',
22 - 'not_empty' => '',
23 - ];
5 +final class Helper
6 +{
7 + // public static function getTableName($className)
8 + // {
9 + // $className = str_replace('\\', '', $className);
10 + // $className = str_replace('Model', '', $className);
11 + // return strtolower($className);
12 + // }
13 + public function arrValueModifyByLogic($operator, $value)
14 + {
15 + $oprators = [
16 + 'equal' => '["' . implode('","', $value) . '"]',
17 + 'not_equal' => '["' . implode('","', $value) . '"]',
18 + 'start_with' => '["' . implode('","', $value) . '"%',
19 + 'not_start_with' => '["' . implode('","', $value) . '"%',
20 + 'end_with' => '%"' . implode('","', $value) . '"]',
21 + 'not_end_with' => '%"' . implode('","', $value) . '"]',
22 + 'contain' => '%"' . implode('","', $value) . '"%',
23 + 'not_contain' => '%"' . implode('","', $value) . '"%',
24 + 'empty' => '',
25 + 'not_empty' => '',
26 + ];
24 27
25 - if ( isset( $oprators[$operator] ) ) {
26 - return $oprators[$operator];
27 - }
28 -
29 - return $value;
28 + if (isset($oprators[$operator])) {
29 + return $oprators[$operator];
30 30 }
31 31
32 - public function dateQueryList() {
33 - return [
34 - 'today' => 'Y-m-d_+0 days_=',
35 - 'till_today' => 'Y-m-d_+0 days_<=',
36 - 'tomorrow' => 'Y-m-d_+1 days_=',
37 - 'till_tomorrow' => 'Y-m-d_+1 days_<=',
38 - 'yesterday' => 'Y-m-d_-1 days_=',
39 - 'till_yesterday' => 'Y-m-d_-1 days_<=',
40 - 'last_7_days' => 'Y-m-d_-7 days_>=',
41 - 'last_30_days' => 'Y-m-d_-30 days_>=',
42 - 'last_60_days' => 'Y-m-d_-60 days_>=',
43 - 'last_90_days' => 'Y-m-d_-90 days_>=',
44 - 'last_120_days' => 'Y-m-d_-120 days_>=',
45 - 'next_7_days' => 'Y-m-d_+7 days_>=',
46 - 'next_30_days' => 'Y-m-d_+30 days_>=',
47 - 'next_60_days' => 'Y-m-d_+60 days_>=',
48 - 'next_90_days' => 'Y-m-d_+90 days_>=',
49 - 'next_120_days' => 'Y-m-d_+120 days_>=',
50 - 'current_month' => 'm_+0 month_=',
51 - 'next_month' => 'm_first day of next month_=',
52 - 'last_month' => 'm_first day of last month_=',
53 - 'current_week' => 'W_0 week_=',
54 - 'next_week' => 'W_+1 week_=',
55 - 'last_week' => 'W_-1 week_=',
56 - 'current_year' => 'Y_+0 year_=',
57 - 'next_year' => 'Y_+1 year_=',
58 - 'last_year' => 'Y_-1 year_=',
59 - ];
60 - }
32 + return $value;
33 + }
61 34
62 - public function strValueModifyByLogic( $operator, $value ) {
63 - $timeInterval = $this->dateQueryList();
35 + public function dateQueryList()
36 + {
37 + return [
38 + 'today' => 'Y-m-d_+0 days_=',
39 + 'till_today' => 'Y-m-d_+0 days_<=',
40 + 'tomorrow' => 'Y-m-d_+1 days_=',
41 + 'till_tomorrow' => 'Y-m-d_+1 days_<=',
42 + 'yesterday' => 'Y-m-d_-1 days_=',
43 + 'till_yesterday' => 'Y-m-d_-1 days_<=',
44 + 'last_7_days' => 'Y-m-d_-7 days_>=',
45 + 'last_30_days' => 'Y-m-d_-30 days_>=',
46 + 'last_60_days' => 'Y-m-d_-60 days_>=',
47 + 'last_90_days' => 'Y-m-d_-90 days_>=',
48 + 'last_120_days' => 'Y-m-d_-120 days_>=',
49 + 'next_7_days' => 'Y-m-d_+7 days_>=',
50 + 'next_30_days' => 'Y-m-d_+30 days_>=',
51 + 'next_60_days' => 'Y-m-d_+60 days_>=',
52 + 'next_90_days' => 'Y-m-d_+90 days_>=',
53 + 'next_120_days' => 'Y-m-d_+120 days_>=',
54 + 'current_month' => 'm_+0 month_=',
55 + 'next_month' => 'm_first day of next month_=',
56 + 'last_month' => 'm_first day of last month_=',
57 + 'current_week' => 'W_0 week_=',
58 + 'next_week' => 'W_+1 week_=',
59 + 'last_week' => 'W_-1 week_=',
60 + 'current_year' => 'Y_+0 year_=',
61 + 'next_year' => 'Y_+1 year_=',
62 + 'last_year' => 'Y_-1 year_=',
63 + ];
64 + }
64 65
65 - if ( isset( $timeInterval[$operator] ) ) {
66 - $data = explode( '_', $timeInterval[$operator] );
67 - if ( is_array( $data ) && count( $data ) > 0 ) {
68 - $value = date( $data[0], strtotime( $data[1] ) );
69 - }
70 - }
66 + public function strValueModifyByLogic($operator, $value)
67 + {
68 + $timeInterval = $this->dateQueryList();
71 69
72 - $oprators = [
73 - 'greater_than' => (int) $value,
74 - 'less_than' => (int) $value,
75 - 'greater_than_equal' => (int) $value,
76 - 'less_than_equal' => (int) $value,
77 - 'start_with' => $value . '%',
78 - 'end_with' => '%' . $value,
79 - 'contain' => '%' . $value . '%',
80 - 'empty' => '',
81 - 'not_empty' => '',
82 - 'not_start_with' => $value . '%',
83 - 'not_end_with' => '%' . $value,
84 - 'not_contain' => '%' . $value . '%',
85 - ];
70 + if (isset($timeInterval[$operator])) {
71 + $data = explode('_', $timeInterval[$operator]);
72 + if (is_array($data) && count($data) > 0) {
73 + $value = date($data[0], strtotime($data[1]));
74 + }
75 + }
86 76
87 - if ( isset( $oprators[$operator] ) ) {
88 - $value = $oprators[$operator];
89 - }
77 + $oprators = [
78 + 'greater_than' => (int) $value,
79 + 'less_than' => (int) $value,
80 + 'greater_than_equal' => (int) $value,
81 + 'less_than_equal' => (int) $value,
82 + 'start_with' => $value . '%',
83 + 'end_with' => '%' . $value,
84 + 'contain' => '%' . $value . '%',
85 + 'empty' => '',
86 + 'not_empty' => '',
87 + 'not_start_with' => $value . '%',
88 + 'not_end_with' => '%' . $value,
89 + 'not_contain' => '%' . $value . '%',
90 + ];
90 91
91 - if ( is_array( $value ) ) {
92 - $value = implode( ',', $value );
93 - }
92 + if (isset($oprators[$operator])) {
93 + $value = $oprators[$operator];
94 + }
94 95
95 - return $value;
96 -
96 + if (is_array($value)) {
97 + $value = implode(',', $value);
97 98 }
98 99
99 - public function convertToSqlOperator( $operator ) {
100 + return $value;
101 + }
100 102
101 - $timeInterval = $this->dateQueryList();
103 + public function convertToSqlOperator($operator)
104 + {
105 + $timeInterval = $this->dateQueryList();
102 106
103 - if ( isset( $timeInterval[$operator] ) ) {
104 - $data = explode( '_', $timeInterval[$operator] );
105 - return $data[2];
106 - }
107 + if (isset($timeInterval[$operator])) {
108 + $data = explode('_', $timeInterval[$operator]);
109 + return $data[2];
110 + }
107 111
108 - $oprators = [
109 - 'greater_than' => '>',
110 - 'less_than' => '<',
111 - 'greater_than_equal' => '>=',
112 - 'less_than_equal' => '<=',
113 - 'equal' => '=',
114 - 'not_equal' => '!=',
115 - 'empty' => '=',
116 - 'not_empty' => '!=',
117 - 'start_with' => 'LIKE',
118 - 'not_start_with' => 'NOT LIKE',
119 - 'end_with' => 'LIKE',
120 - 'not_end_with' => 'NOT LIKE',
121 - 'contain' => 'LIKE',
122 - 'not_contain' => 'NOT LIKE',
123 - ];
112 + $oprators = [
113 + 'greater_than' => '>',
114 + 'less_than' => '<',
115 + 'greater_than_equal' => '>=',
116 + 'less_than_equal' => '<=',
117 + 'equal' => '=',
118 + 'not_equal' => '!=',
119 + 'empty' => '=',
120 + 'not_empty' => '!=',
121 + 'start_with' => 'LIKE',
122 + 'not_start_with' => 'NOT LIKE',
123 + 'end_with' => 'LIKE',
124 + 'not_end_with' => 'NOT LIKE',
125 + 'contain' => 'LIKE',
126 + 'not_contain' => 'NOT LIKE',
127 + ];
124 128
125 - if ( isset( $oprators[$operator] ) ) {
126 - return $oprators[$operator];
127 - }
128 -
129 - return $operator;
129 + if (isset($oprators[$operator])) {
130 + return $oprators[$operator];
130 131 }
131 132
132 - public function fieldQueryByDate( $fld, $operator, $value, $logic ) {
133 + return $operator;
134 + }
133 135
134 - $currentYear = date( 'Y' );
136 + public function fieldQueryByDate($fld, $operator, $value, $logic)
137 + {
138 + $currentYear = date('Y');
135 139
136 - $sql = '';
140 + $sql = '';
137 141
138 - $daysInterval = [
139 - 'today',
140 - 'till_today',
141 - 'tomorrow',
142 - 'till_tomorrow',
143 - 'yesterday',
144 - 'till_yesterday',
145 - 'last_7_days',
146 - 'last_30_days',
147 - 'last_60_days',
148 - 'last_90_days',
149 - 'last_120_days',
150 - 'next_7_days',
151 - 'next_30_days',
152 - 'next_60_days',
153 - 'next_90_days',
154 - 'next_120_days',
155 - ];
156 - if ( in_array( $logic, $daysInterval ) ) {
157 - $sql = "`$fld` $operator '$value'";
158 - }
142 + $daysInterval = [
143 + 'today',
144 + 'till_today',
145 + 'tomorrow',
146 + 'till_tomorrow',
147 + 'yesterday',
148 + 'till_yesterday',
149 + 'last_7_days',
150 + 'last_30_days',
151 + 'last_60_days',
152 + 'last_90_days',
153 + 'last_120_days',
154 + 'next_7_days',
155 + 'next_30_days',
156 + 'next_60_days',
157 + 'next_90_days',
158 + 'next_120_days',
159 + ];
160 + if (in_array($logic, $daysInterval)) {
161 + $sql = "`$fld` $operator '$value'";
162 + }
159 163
160 - if ( in_array( $logic, ['current_month', 'next_month', 'last_month'] ) ) {
161 - $sql = "MONTH(`$fld`) $operator '$value' AND YEAR(`$fld`) = '$currentYear'";
162 - }
164 + if (in_array($logic, ['current_month', 'next_month', 'last_month'])) {
165 + $sql = "MONTH(`$fld`) $operator '$value' AND YEAR(`$fld`) = '$currentYear'";
166 + }
163 167
164 - if ( in_array( $logic, ['current_week', 'next_week', 'last_week'] ) ) {
165 - $sql = "WEEK(`$fld`) $operator '$value' AND YEAR(`$fld`) = $currentYear";
166 - }
167 - return $sql;
168 + if (in_array($logic, ['current_week', 'next_week', 'last_week'])) {
169 + $sql = "WEEK(`$fld`) $operator '$value' AND YEAR(`$fld`) = $currentYear";
168 170 }
171 + return $sql;
172 + }
169 173 }