@@ -60,10 +60,11 @@ public function select(string ...$columns): self
6060 * Adds a filter condition with an "and" clause.
6161 *
6262 * @param string $columnName
63+ * @param string $operator
6364 * @param bool|int|float|string|array $expectedValue
6465 * @return $this
6566 */
66- public function andWhereEquals (string $ columnName , $ expectedValue ): self
67+ protected function andWhere (string $ columnName, $ operator , $ expectedValue ): self
6768 {
6869 if (!empty ($ this ->filter )) {
6970 $ this ->filter .= " and " ;
@@ -74,17 +75,53 @@ public function andWhereEquals(string $columnName, $expectedValue): self
7475 }
7576
7677 if (is_integer ($ expectedValue ) || is_float ($ expectedValue )) {
77- $ this ->filter .= "{$ columnName } eq {$ expectedValue }" ;
78+ $ this ->filter .= "{$ columnName } { $ operator } {$ expectedValue }" ;
7879 } else if (is_string ($ expectedValue )) {
79- $ this ->filter .= "{$ columnName } eq ' {$ expectedValue }' " ;
80- } else if (is_array ($ expectedValue )) {
80+ $ this ->filter .= "{$ columnName } { $ operator } ' {$ expectedValue }' " ;
81+ } else if (( $ operator === " eq " || $ operator === " equals " || $ operator === " oneOf " ) && is_array ($ expectedValue )) {
8182 $ oneOfList = "' " . implode ("',' " , $ expectedValue ) . "' " ;
8283 $ this ->filter .= "{$ columnName } oneOf( {$ oneOfList }) " ;
8384 }
8485
8586 return $ this ;
8687 }
8788
89+ /**
90+ * Adds a filter condition with an "and equals" clause.
91+ *
92+ * @param string $columnName
93+ * @param bool|int|float|string|array $expectedValue
94+ * @return $this
95+ */
96+ public function andWhereEquals (string $ columnName , $ expectedValue ): self
97+ {
98+ return $ this ->andWhere ($ columnName , "eq " , $ expectedValue );
99+ }
100+
101+ /**
102+ * Adds a filter condition with an "and greater than" clause.
103+ *
104+ * @param string $columnName
105+ * @param int|float $expectedValue
106+ * @return $this
107+ */
108+ public function andWhereGreaterThan (string $ columnName , $ expectedValue ): self
109+ {
110+ return $ this ->andWhere ($ columnName , "gt " , $ expectedValue );
111+ }
112+
113+ /**
114+ * Adds a filter condition with an "and less than" clause.
115+ *
116+ * @param string $columnName
117+ * @param int|float $expectedValue
118+ * @return $this
119+ */
120+ public function andWhereLessThan (string $ columnName , $ expectedValue ): self
121+ {
122+ return $ this ->andWhere ($ columnName , "lt " , $ expectedValue );
123+ }
124+
88125 /**
89126 * Set query limit ($top).
90127 *
0 commit comments