|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace Imi\Db\Query\Interfaces; |
| 6 | + |
| 7 | +interface IBaseWhereCollector |
| 8 | +{ |
| 9 | + /** |
| 10 | + * 设置 where 条件,一般用于 =、>、<、like等. |
| 11 | + * |
| 12 | + * @param mixed $value |
| 13 | + * |
| 14 | + * @return static |
| 15 | + */ |
| 16 | + public function where(string $fieldName, string $operation, $value, string $logicalOperator = 'and'): self; |
| 17 | + |
| 18 | + /** |
| 19 | + * 设置 where 条件,用原生语句. |
| 20 | + * |
| 21 | + * @return static |
| 22 | + */ |
| 23 | + public function whereRaw(string $raw, string $logicalOperator = 'and', array $binds = []): self; |
| 24 | + |
| 25 | + /** |
| 26 | + * 设置 where 条件,传入回调,回调中的条件加括号. |
| 27 | + * |
| 28 | + * @return static |
| 29 | + */ |
| 30 | + public function whereBrackets(callable $callback, string $logicalOperator = 'and'): self; |
| 31 | + |
| 32 | + /** |
| 33 | + * 设置 where 条件,使用 IBaseWhere 结构. |
| 34 | + * |
| 35 | + * @return static |
| 36 | + */ |
| 37 | + public function whereStruct(IBaseWhere $where, string $logicalOperator = 'and'): self; |
| 38 | + |
| 39 | + /** |
| 40 | + * 设置 where 条件,支持语法如下:. |
| 41 | + * |
| 42 | + * [ |
| 43 | + * 'id' => 1, |
| 44 | + * 'or' => [ |
| 45 | + * 'id' => 2, |
| 46 | + * ], |
| 47 | + * 'title' => ['like', '%test%'], |
| 48 | + * 'age' => ['>', 18], |
| 49 | + * 'age' => ['between', 19, 29] |
| 50 | + * ] |
| 51 | + * |
| 52 | + * SQL: id = 1 or (id = 2) and title like '%test%' and age > 18 and age between 19 and 29 |
| 53 | + * |
| 54 | + * @return static |
| 55 | + */ |
| 56 | + public function whereEx(array $condition, string $logicalOperator = 'and'): self; |
| 57 | + |
| 58 | + /** |
| 59 | + * where between $begin end $end. |
| 60 | + * |
| 61 | + * @param mixed $begin |
| 62 | + * @param mixed $end |
| 63 | + * |
| 64 | + * @return static |
| 65 | + */ |
| 66 | + public function whereBetween(string $fieldName, $begin, $end, string $logicalOperator = 'and'): self; |
| 67 | + |
| 68 | + /** |
| 69 | + * or where between $begin end $end. |
| 70 | + * |
| 71 | + * @param mixed $begin |
| 72 | + * @param mixed $end |
| 73 | + * |
| 74 | + * @return static |
| 75 | + */ |
| 76 | + public function orWhereBetween(string $fieldName, $begin, $end): self; |
| 77 | + |
| 78 | + /** |
| 79 | + * where not between $begin end $end. |
| 80 | + * |
| 81 | + * @param mixed $begin |
| 82 | + * @param mixed $end |
| 83 | + * |
| 84 | + * @return static |
| 85 | + */ |
| 86 | + public function whereNotBetween(string $fieldName, $begin, $end, string $logicalOperator = 'and'): self; |
| 87 | + |
| 88 | + /** |
| 89 | + * or where not between $begin end $end. |
| 90 | + * |
| 91 | + * @param mixed $begin |
| 92 | + * @param mixed $end |
| 93 | + * |
| 94 | + * @return static |
| 95 | + */ |
| 96 | + public function orWhereNotBetween(string $fieldName, $begin, $end): self; |
| 97 | + |
| 98 | + /** |
| 99 | + * 设置 where or 条件. |
| 100 | + * |
| 101 | + * @param mixed $value |
| 102 | + * |
| 103 | + * @return static |
| 104 | + */ |
| 105 | + public function orWhere(string $fieldName, string $operation, $value): self; |
| 106 | + |
| 107 | + /** |
| 108 | + * 设置 where or 条件,用原生语句. |
| 109 | + * |
| 110 | + * @return static |
| 111 | + */ |
| 112 | + public function orWhereRaw(string $where, array $binds = []): self; |
| 113 | + |
| 114 | + /** |
| 115 | + * 设置 where or 条件,传入回调,回调中的条件加括号. |
| 116 | + * |
| 117 | + * @return static |
| 118 | + */ |
| 119 | + public function orWhereBrackets(callable $callback): self; |
| 120 | + |
| 121 | + /** |
| 122 | + * 设置 where or 条件,使用 IBaseWhere 结构. |
| 123 | + * |
| 124 | + * @return static |
| 125 | + */ |
| 126 | + public function orWhereStruct(IBaseWhere $where): self; |
| 127 | + |
| 128 | + /** |
| 129 | + * 设置 where or 条件,支持语法参考 whereEx 方法. |
| 130 | + * |
| 131 | + * @return static |
| 132 | + */ |
| 133 | + public function orWhereEx(array $condition): self; |
| 134 | + |
| 135 | + /** |
| 136 | + * where field in (list). |
| 137 | + * |
| 138 | + * @return static |
| 139 | + */ |
| 140 | + public function whereIn(string $fieldName, array $list, string $logicalOperator = 'and'): self; |
| 141 | + |
| 142 | + /** |
| 143 | + * or where field in (list). |
| 144 | + * |
| 145 | + * @return static |
| 146 | + */ |
| 147 | + public function orWhereIn(string $fieldName, array $list): self; |
| 148 | + |
| 149 | + /** |
| 150 | + * where field not in (list). |
| 151 | + * |
| 152 | + * @return static |
| 153 | + */ |
| 154 | + public function whereNotIn(string $fieldName, array $list, string $logicalOperator = 'and'): self; |
| 155 | + |
| 156 | + /** |
| 157 | + * or where field not in (list). |
| 158 | + * |
| 159 | + * @return static |
| 160 | + */ |
| 161 | + public function orWhereNotIn(string $fieldName, array $list): self; |
| 162 | + |
| 163 | + /** |
| 164 | + * where field is null. |
| 165 | + * |
| 166 | + * @return static |
| 167 | + */ |
| 168 | + public function whereIsNull(string $fieldName, string $logicalOperator = 'and'): self; |
| 169 | + |
| 170 | + /** |
| 171 | + * or where field is null. |
| 172 | + * |
| 173 | + * @return static |
| 174 | + */ |
| 175 | + public function orWhereIsNull(string $fieldName): self; |
| 176 | + |
| 177 | + /** |
| 178 | + * where field is not null. |
| 179 | + * |
| 180 | + * @return static |
| 181 | + */ |
| 182 | + public function whereIsNotNull(string $fieldName, string $logicalOperator = 'and'): self; |
| 183 | + |
| 184 | + /** |
| 185 | + * or where field is not null. |
| 186 | + * |
| 187 | + * @return static |
| 188 | + */ |
| 189 | + public function orWhereIsNotNull(string $fieldName): self; |
| 190 | +} |
0 commit comments