@@ -126,4 +126,123 @@ public static function not(RawValue $value): RawValue
126126 {
127127 return new RawValue ("NOT ( " . $ value ->getValue () . ") " , $ value ->getParams ());
128128 }
129+
130+ /**
131+ * Returns a RawValue instance representing a BETWEEN condition.
132+ *
133+ * @param string $column The column name.
134+ * @param mixed $min The minimum value.
135+ * @param mixed $max The maximum value.
136+ * @return RawValue The RawValue instance for the BETWEEN condition.
137+ */
138+ public static function between (string $ column , mixed $ min , mixed $ max ): RawValue
139+ {
140+ return new RawValue ("$ column BETWEEN :min AND :max " , ['min ' => $ min , 'max ' => $ max ]);
141+ }
142+
143+ /**
144+ * Returns a RawValue instance representing a NOT BETWEEN condition.
145+ *
146+ * @param string $column The column name.
147+ * @param mixed $min The minimum value.
148+ * @param mixed $max The maximum value.
149+ * @return RawValue The RawValue instance for the NOT BETWEEN condition.
150+ */
151+ public static function notBetween (string $ column , mixed $ min , mixed $ max ): RawValue
152+ {
153+ return new RawValue ("$ column NOT BETWEEN :min AND :max " , ['min ' => $ min , 'max ' => $ max ]);
154+ }
155+
156+ /**
157+ * Returns a RawValue instance representing an IN condition.
158+ *
159+ * @param string $column The column name.
160+ * @param array $values The array of values for the IN condition.
161+ * @return RawValue The RawValue instance for the IN condition.
162+ */
163+ public static function in (string $ column , array $ values ): RawValue
164+ {
165+ $ params = [];
166+ $ placeholders = [];
167+
168+ foreach ($ values as $ i => $ val ) {
169+ $ key = "in_ {$ column }_ $ i " ;
170+ $ params [$ key ] = $ val ;
171+ $ placeholders [] = ": $ key " ;
172+ }
173+
174+ return new RawValue ("$ column IN ( " . implode (', ' , $ placeholders ) . ") " , $ params );
175+ }
176+
177+ /**
178+ * Returns a RawValue instance representing a NOT IN condition.
179+ *
180+ * @param string $column The column name.
181+ * @param array $values The array of values for the NOT IN condition.
182+ * @return RawValue The RawValue instance for the NOT IN condition.
183+ */
184+ public static function notIn (string $ column , array $ values ): RawValue
185+ {
186+ $ params = [];
187+ $ placeholders = [];
188+
189+ foreach ($ values as $ i => $ val ) {
190+ $ key = "in_ {$ column }_ $ i " ;
191+ $ params [$ key ] = $ val ;
192+ $ placeholders [] = ": $ key " ;
193+ }
194+
195+ return new RawValue ("$ column NOT IN ( " . implode (', ' , $ placeholders ) . ") " , $ params );
196+ }
197+
198+ /**
199+ * Returns a RawValue instance representing an IS NULL condition.
200+ * @param string $column The column name.
201+ * @return RawValue
202+ */
203+ public static function isNull (string $ column ): RawValue
204+ {
205+ return new RawValue ("$ column IS NULL " );
206+ }
207+
208+ /**
209+ * Returns a RawValue instance representing an IS NULL condition.
210+ * @param string $column The column name.
211+ * @return RawValue
212+ */
213+ public static function isNotNull (string $ column ): RawValue
214+ {
215+ return new RawValue ("$ column IS NOT NULL " );
216+ }
217+
218+ /**
219+ * Returns a RawValue instance representing a CASE statement.
220+ *
221+ * @param array $cases An associative array where keys are WHEN conditions and values are THEN results.
222+ * @param string|null $else An optional ELSE result.
223+ * @return CaseValue The RawValue instance for the CASE statement.
224+ */
225+ public static function case (array $ cases , string |null $ else = null ): CaseValue
226+ {
227+ $ sql = 'CASE ' ;
228+ foreach ($ cases as $ when => $ then ) {
229+ $ sql .= " WHEN $ when THEN $ then " ;
230+ }
231+ if ($ else !== null ) {
232+ $ sql .= " ELSE $ else " ;
233+ }
234+ $ sql .= ' END ' ;
235+
236+ return new CaseValue ($ sql );
237+ }
238+
239+ /**
240+ * Returns a RawValue instance representing SQL DEFAULT.
241+ *
242+ * @return RawValue The RawValue instance for DEFAULT.
243+ */
244+ public static function default (): RawValue
245+ {
246+ return new RawValue ('DEFAULT ' );
247+ }
129248}
0 commit comments