@@ -36,409 +36,409 @@ |
||
| 36 | 36 | * @psalm-taint-specialize |
| 37 | 37 | */ |
| 38 | 38 | interface IExpressionBuilder { |
| 39 | - /** |
|
| 40 | - * @since 9.0.0 |
|
| 41 | - */ |
|
| 42 | - public const EQ = ExpressionBuilder::EQ; |
|
| 43 | - /** |
|
| 44 | - * @since 9.0.0 |
|
| 45 | - */ |
|
| 46 | - public const NEQ = ExpressionBuilder::NEQ; |
|
| 47 | - /** |
|
| 48 | - * @since 9.0.0 |
|
| 49 | - */ |
|
| 50 | - public const LT = ExpressionBuilder::LT; |
|
| 51 | - /** |
|
| 52 | - * @since 9.0.0 |
|
| 53 | - */ |
|
| 54 | - public const LTE = ExpressionBuilder::LTE; |
|
| 55 | - /** |
|
| 56 | - * @since 9.0.0 |
|
| 57 | - */ |
|
| 58 | - public const GT = ExpressionBuilder::GT; |
|
| 59 | - /** |
|
| 60 | - * @since 9.0.0 |
|
| 61 | - */ |
|
| 62 | - public const GTE = ExpressionBuilder::GTE; |
|
| 39 | + /** |
|
| 40 | + * @since 9.0.0 |
|
| 41 | + */ |
|
| 42 | + public const EQ = ExpressionBuilder::EQ; |
|
| 43 | + /** |
|
| 44 | + * @since 9.0.0 |
|
| 45 | + */ |
|
| 46 | + public const NEQ = ExpressionBuilder::NEQ; |
|
| 47 | + /** |
|
| 48 | + * @since 9.0.0 |
|
| 49 | + */ |
|
| 50 | + public const LT = ExpressionBuilder::LT; |
|
| 51 | + /** |
|
| 52 | + * @since 9.0.0 |
|
| 53 | + */ |
|
| 54 | + public const LTE = ExpressionBuilder::LTE; |
|
| 55 | + /** |
|
| 56 | + * @since 9.0.0 |
|
| 57 | + */ |
|
| 58 | + public const GT = ExpressionBuilder::GT; |
|
| 59 | + /** |
|
| 60 | + * @since 9.0.0 |
|
| 61 | + */ |
|
| 62 | + public const GTE = ExpressionBuilder::GTE; |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * Creates a conjunction of the given boolean expressions. |
|
| 66 | - * |
|
| 67 | - * Example: |
|
| 68 | - * |
|
| 69 | - * [php] |
|
| 70 | - * // (u.type = ?) AND (u.role = ?) |
|
| 71 | - * $expr->andX('u.type = ?', 'u.role = ?')); |
|
| 72 | - * |
|
| 73 | - * @param mixed ...$x Optional clause. Defaults = null, but requires |
|
| 74 | - * at least one defined when converting to string. |
|
| 75 | - * |
|
| 76 | - * @return \OCP\DB\QueryBuilder\ICompositeExpression |
|
| 77 | - * @since 8.2.0 |
|
| 78 | - * |
|
| 79 | - * @psalm-taint-sink sql $x |
|
| 80 | - */ |
|
| 81 | - public function andX(...$x): ICompositeExpression; |
|
| 64 | + /** |
|
| 65 | + * Creates a conjunction of the given boolean expressions. |
|
| 66 | + * |
|
| 67 | + * Example: |
|
| 68 | + * |
|
| 69 | + * [php] |
|
| 70 | + * // (u.type = ?) AND (u.role = ?) |
|
| 71 | + * $expr->andX('u.type = ?', 'u.role = ?')); |
|
| 72 | + * |
|
| 73 | + * @param mixed ...$x Optional clause. Defaults = null, but requires |
|
| 74 | + * at least one defined when converting to string. |
|
| 75 | + * |
|
| 76 | + * @return \OCP\DB\QueryBuilder\ICompositeExpression |
|
| 77 | + * @since 8.2.0 |
|
| 78 | + * |
|
| 79 | + * @psalm-taint-sink sql $x |
|
| 80 | + */ |
|
| 81 | + public function andX(...$x): ICompositeExpression; |
|
| 82 | 82 | |
| 83 | - /** |
|
| 84 | - * Creates a disjunction of the given boolean expressions. |
|
| 85 | - * |
|
| 86 | - * Example: |
|
| 87 | - * |
|
| 88 | - * [php] |
|
| 89 | - * // (u.type = ?) OR (u.role = ?) |
|
| 90 | - * $qb->where($qb->expr()->orX('u.type = ?', 'u.role = ?')); |
|
| 91 | - * |
|
| 92 | - * @param mixed ...$x Optional clause. Defaults = null, but requires |
|
| 93 | - * at least one defined when converting to string. |
|
| 94 | - * |
|
| 95 | - * @return \OCP\DB\QueryBuilder\ICompositeExpression |
|
| 96 | - * @since 8.2.0 |
|
| 97 | - * |
|
| 98 | - * @psalm-taint-sink sql $x |
|
| 99 | - */ |
|
| 100 | - public function orX(...$x): ICompositeExpression; |
|
| 83 | + /** |
|
| 84 | + * Creates a disjunction of the given boolean expressions. |
|
| 85 | + * |
|
| 86 | + * Example: |
|
| 87 | + * |
|
| 88 | + * [php] |
|
| 89 | + * // (u.type = ?) OR (u.role = ?) |
|
| 90 | + * $qb->where($qb->expr()->orX('u.type = ?', 'u.role = ?')); |
|
| 91 | + * |
|
| 92 | + * @param mixed ...$x Optional clause. Defaults = null, but requires |
|
| 93 | + * at least one defined when converting to string. |
|
| 94 | + * |
|
| 95 | + * @return \OCP\DB\QueryBuilder\ICompositeExpression |
|
| 96 | + * @since 8.2.0 |
|
| 97 | + * |
|
| 98 | + * @psalm-taint-sink sql $x |
|
| 99 | + */ |
|
| 100 | + public function orX(...$x): ICompositeExpression; |
|
| 101 | 101 | |
| 102 | - /** |
|
| 103 | - * Creates a comparison expression. |
|
| 104 | - * |
|
| 105 | - * @param mixed $x The left expression. |
|
| 106 | - * @param string $operator One of the IExpressionBuilder::* constants. |
|
| 107 | - * @param mixed $y The right expression. |
|
| 108 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 109 | - * required when comparing text fields for oci compatibility |
|
| 110 | - * |
|
| 111 | - * @return string |
|
| 112 | - * @since 8.2.0 - Parameter $type was added in 9.0.0 |
|
| 113 | - * |
|
| 114 | - * @psalm-taint-sink sql $x |
|
| 115 | - * @psalm-taint-sink sql $operator |
|
| 116 | - * @psalm-taint-sink sql $y |
|
| 117 | - * @psalm-taint-sink sql $type |
|
| 118 | - */ |
|
| 119 | - public function comparison($x, string $operator, $y, $type = null): string; |
|
| 102 | + /** |
|
| 103 | + * Creates a comparison expression. |
|
| 104 | + * |
|
| 105 | + * @param mixed $x The left expression. |
|
| 106 | + * @param string $operator One of the IExpressionBuilder::* constants. |
|
| 107 | + * @param mixed $y The right expression. |
|
| 108 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 109 | + * required when comparing text fields for oci compatibility |
|
| 110 | + * |
|
| 111 | + * @return string |
|
| 112 | + * @since 8.2.0 - Parameter $type was added in 9.0.0 |
|
| 113 | + * |
|
| 114 | + * @psalm-taint-sink sql $x |
|
| 115 | + * @psalm-taint-sink sql $operator |
|
| 116 | + * @psalm-taint-sink sql $y |
|
| 117 | + * @psalm-taint-sink sql $type |
|
| 118 | + */ |
|
| 119 | + public function comparison($x, string $operator, $y, $type = null): string; |
|
| 120 | 120 | |
| 121 | - /** |
|
| 122 | - * Creates an equality comparison expression with the given arguments. |
|
| 123 | - * |
|
| 124 | - * First argument is considered the left expression and the second is the right expression. |
|
| 125 | - * When converted to string, it will generated a <left expr> = <right expr>. Example: |
|
| 126 | - * |
|
| 127 | - * [php] |
|
| 128 | - * // u.id = ? |
|
| 129 | - * $expr->eq('u.id', '?'); |
|
| 130 | - * |
|
| 131 | - * @param mixed $x The left expression. |
|
| 132 | - * @param mixed $y The right expression. |
|
| 133 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 134 | - * required when comparing text fields for oci compatibility |
|
| 135 | - * |
|
| 136 | - * @return string |
|
| 137 | - * @since 8.2.0 - Parameter $type was added in 9.0.0 |
|
| 138 | - * |
|
| 139 | - * @psalm-taint-sink sql $x |
|
| 140 | - * @psalm-taint-sink sql $y |
|
| 141 | - * @psalm-taint-sink sql $type |
|
| 142 | - */ |
|
| 143 | - public function eq($x, $y, $type = null): string; |
|
| 121 | + /** |
|
| 122 | + * Creates an equality comparison expression with the given arguments. |
|
| 123 | + * |
|
| 124 | + * First argument is considered the left expression and the second is the right expression. |
|
| 125 | + * When converted to string, it will generated a <left expr> = <right expr>. Example: |
|
| 126 | + * |
|
| 127 | + * [php] |
|
| 128 | + * // u.id = ? |
|
| 129 | + * $expr->eq('u.id', '?'); |
|
| 130 | + * |
|
| 131 | + * @param mixed $x The left expression. |
|
| 132 | + * @param mixed $y The right expression. |
|
| 133 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 134 | + * required when comparing text fields for oci compatibility |
|
| 135 | + * |
|
| 136 | + * @return string |
|
| 137 | + * @since 8.2.0 - Parameter $type was added in 9.0.0 |
|
| 138 | + * |
|
| 139 | + * @psalm-taint-sink sql $x |
|
| 140 | + * @psalm-taint-sink sql $y |
|
| 141 | + * @psalm-taint-sink sql $type |
|
| 142 | + */ |
|
| 143 | + public function eq($x, $y, $type = null): string; |
|
| 144 | 144 | |
| 145 | - /** |
|
| 146 | - * Creates a non equality comparison expression with the given arguments. |
|
| 147 | - * First argument is considered the left expression and the second is the right expression. |
|
| 148 | - * When converted to string, it will generated a <left expr> <> <right expr>. Example: |
|
| 149 | - * |
|
| 150 | - * [php] |
|
| 151 | - * // u.id <> 1 |
|
| 152 | - * $q->where($q->expr()->neq('u.id', '1')); |
|
| 153 | - * |
|
| 154 | - * @param mixed $x The left expression. |
|
| 155 | - * @param mixed $y The right expression. |
|
| 156 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 157 | - * required when comparing text fields for oci compatibility |
|
| 158 | - * |
|
| 159 | - * @return string |
|
| 160 | - * @since 8.2.0 - Parameter $type was added in 9.0.0 |
|
| 161 | - * |
|
| 162 | - * @psalm-taint-sink sql $x |
|
| 163 | - * @psalm-taint-sink sql $y |
|
| 164 | - * @psalm-taint-sink sql $type |
|
| 165 | - */ |
|
| 166 | - public function neq($x, $y, $type = null): string; |
|
| 145 | + /** |
|
| 146 | + * Creates a non equality comparison expression with the given arguments. |
|
| 147 | + * First argument is considered the left expression and the second is the right expression. |
|
| 148 | + * When converted to string, it will generated a <left expr> <> <right expr>. Example: |
|
| 149 | + * |
|
| 150 | + * [php] |
|
| 151 | + * // u.id <> 1 |
|
| 152 | + * $q->where($q->expr()->neq('u.id', '1')); |
|
| 153 | + * |
|
| 154 | + * @param mixed $x The left expression. |
|
| 155 | + * @param mixed $y The right expression. |
|
| 156 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 157 | + * required when comparing text fields for oci compatibility |
|
| 158 | + * |
|
| 159 | + * @return string |
|
| 160 | + * @since 8.2.0 - Parameter $type was added in 9.0.0 |
|
| 161 | + * |
|
| 162 | + * @psalm-taint-sink sql $x |
|
| 163 | + * @psalm-taint-sink sql $y |
|
| 164 | + * @psalm-taint-sink sql $type |
|
| 165 | + */ |
|
| 166 | + public function neq($x, $y, $type = null): string; |
|
| 167 | 167 | |
| 168 | - /** |
|
| 169 | - * Creates a lower-than comparison expression with the given arguments. |
|
| 170 | - * First argument is considered the left expression and the second is the right expression. |
|
| 171 | - * When converted to string, it will generated a <left expr> < <right expr>. Example: |
|
| 172 | - * |
|
| 173 | - * [php] |
|
| 174 | - * // u.id < ? |
|
| 175 | - * $q->where($q->expr()->lt('u.id', '?')); |
|
| 176 | - * |
|
| 177 | - * @param mixed $x The left expression. |
|
| 178 | - * @param mixed $y The right expression. |
|
| 179 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 180 | - * required when comparing text fields for oci compatibility |
|
| 181 | - * |
|
| 182 | - * @return string |
|
| 183 | - * @since 8.2.0 - Parameter $type was added in 9.0.0 |
|
| 184 | - * |
|
| 185 | - * @psalm-taint-sink sql $x |
|
| 186 | - * @psalm-taint-sink sql $y |
|
| 187 | - * @psalm-taint-sink sql $type |
|
| 188 | - */ |
|
| 189 | - public function lt($x, $y, $type = null): string; |
|
| 168 | + /** |
|
| 169 | + * Creates a lower-than comparison expression with the given arguments. |
|
| 170 | + * First argument is considered the left expression and the second is the right expression. |
|
| 171 | + * When converted to string, it will generated a <left expr> < <right expr>. Example: |
|
| 172 | + * |
|
| 173 | + * [php] |
|
| 174 | + * // u.id < ? |
|
| 175 | + * $q->where($q->expr()->lt('u.id', '?')); |
|
| 176 | + * |
|
| 177 | + * @param mixed $x The left expression. |
|
| 178 | + * @param mixed $y The right expression. |
|
| 179 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 180 | + * required when comparing text fields for oci compatibility |
|
| 181 | + * |
|
| 182 | + * @return string |
|
| 183 | + * @since 8.2.0 - Parameter $type was added in 9.0.0 |
|
| 184 | + * |
|
| 185 | + * @psalm-taint-sink sql $x |
|
| 186 | + * @psalm-taint-sink sql $y |
|
| 187 | + * @psalm-taint-sink sql $type |
|
| 188 | + */ |
|
| 189 | + public function lt($x, $y, $type = null): string; |
|
| 190 | 190 | |
| 191 | - /** |
|
| 192 | - * Creates a lower-than-equal comparison expression with the given arguments. |
|
| 193 | - * First argument is considered the left expression and the second is the right expression. |
|
| 194 | - * When converted to string, it will generated a <left expr> <= <right expr>. Example: |
|
| 195 | - * |
|
| 196 | - * [php] |
|
| 197 | - * // u.id <= ? |
|
| 198 | - * $q->where($q->expr()->lte('u.id', '?')); |
|
| 199 | - * |
|
| 200 | - * @param mixed $x The left expression. |
|
| 201 | - * @param mixed $y The right expression. |
|
| 202 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 203 | - * required when comparing text fields for oci compatibility |
|
| 204 | - * |
|
| 205 | - * @return string |
|
| 206 | - * @since 8.2.0 - Parameter $type was added in 9.0.0 |
|
| 207 | - * |
|
| 208 | - * @psalm-taint-sink sql $x |
|
| 209 | - * @psalm-taint-sink sql $y |
|
| 210 | - * @psalm-taint-sink sql $type |
|
| 211 | - */ |
|
| 212 | - public function lte($x, $y, $type = null): string; |
|
| 191 | + /** |
|
| 192 | + * Creates a lower-than-equal comparison expression with the given arguments. |
|
| 193 | + * First argument is considered the left expression and the second is the right expression. |
|
| 194 | + * When converted to string, it will generated a <left expr> <= <right expr>. Example: |
|
| 195 | + * |
|
| 196 | + * [php] |
|
| 197 | + * // u.id <= ? |
|
| 198 | + * $q->where($q->expr()->lte('u.id', '?')); |
|
| 199 | + * |
|
| 200 | + * @param mixed $x The left expression. |
|
| 201 | + * @param mixed $y The right expression. |
|
| 202 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 203 | + * required when comparing text fields for oci compatibility |
|
| 204 | + * |
|
| 205 | + * @return string |
|
| 206 | + * @since 8.2.0 - Parameter $type was added in 9.0.0 |
|
| 207 | + * |
|
| 208 | + * @psalm-taint-sink sql $x |
|
| 209 | + * @psalm-taint-sink sql $y |
|
| 210 | + * @psalm-taint-sink sql $type |
|
| 211 | + */ |
|
| 212 | + public function lte($x, $y, $type = null): string; |
|
| 213 | 213 | |
| 214 | - /** |
|
| 215 | - * Creates a greater-than comparison expression with the given arguments. |
|
| 216 | - * First argument is considered the left expression and the second is the right expression. |
|
| 217 | - * When converted to string, it will generated a <left expr> > <right expr>. Example: |
|
| 218 | - * |
|
| 219 | - * [php] |
|
| 220 | - * // u.id > ? |
|
| 221 | - * $q->where($q->expr()->gt('u.id', '?')); |
|
| 222 | - * |
|
| 223 | - * @param mixed $x The left expression. |
|
| 224 | - * @param mixed $y The right expression. |
|
| 225 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 226 | - * required when comparing text fields for oci compatibility |
|
| 227 | - * |
|
| 228 | - * @return string |
|
| 229 | - * @since 8.2.0 - Parameter $type was added in 9.0.0 |
|
| 230 | - * |
|
| 231 | - * @psalm-taint-sink sql $x |
|
| 232 | - * @psalm-taint-sink sql $y |
|
| 233 | - * @psalm-taint-sink sql $type |
|
| 234 | - */ |
|
| 235 | - public function gt($x, $y, $type = null): string; |
|
| 214 | + /** |
|
| 215 | + * Creates a greater-than comparison expression with the given arguments. |
|
| 216 | + * First argument is considered the left expression and the second is the right expression. |
|
| 217 | + * When converted to string, it will generated a <left expr> > <right expr>. Example: |
|
| 218 | + * |
|
| 219 | + * [php] |
|
| 220 | + * // u.id > ? |
|
| 221 | + * $q->where($q->expr()->gt('u.id', '?')); |
|
| 222 | + * |
|
| 223 | + * @param mixed $x The left expression. |
|
| 224 | + * @param mixed $y The right expression. |
|
| 225 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 226 | + * required when comparing text fields for oci compatibility |
|
| 227 | + * |
|
| 228 | + * @return string |
|
| 229 | + * @since 8.2.0 - Parameter $type was added in 9.0.0 |
|
| 230 | + * |
|
| 231 | + * @psalm-taint-sink sql $x |
|
| 232 | + * @psalm-taint-sink sql $y |
|
| 233 | + * @psalm-taint-sink sql $type |
|
| 234 | + */ |
|
| 235 | + public function gt($x, $y, $type = null): string; |
|
| 236 | 236 | |
| 237 | - /** |
|
| 238 | - * Creates a greater-than-equal comparison expression with the given arguments. |
|
| 239 | - * First argument is considered the left expression and the second is the right expression. |
|
| 240 | - * When converted to string, it will generated a <left expr> >= <right expr>. Example: |
|
| 241 | - * |
|
| 242 | - * [php] |
|
| 243 | - * // u.id >= ? |
|
| 244 | - * $q->where($q->expr()->gte('u.id', '?')); |
|
| 245 | - * |
|
| 246 | - * @param mixed $x The left expression. |
|
| 247 | - * @param mixed $y The right expression. |
|
| 248 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 249 | - * required when comparing text fields for oci compatibility |
|
| 250 | - * |
|
| 251 | - * @return string |
|
| 252 | - * @since 8.2.0 - Parameter $type was added in 9.0.0 |
|
| 253 | - * |
|
| 254 | - * @psalm-taint-sink sql $x |
|
| 255 | - * @psalm-taint-sink sql $y |
|
| 256 | - * @psalm-taint-sink sql $type |
|
| 257 | - */ |
|
| 258 | - public function gte($x, $y, $type = null): string; |
|
| 237 | + /** |
|
| 238 | + * Creates a greater-than-equal comparison expression with the given arguments. |
|
| 239 | + * First argument is considered the left expression and the second is the right expression. |
|
| 240 | + * When converted to string, it will generated a <left expr> >= <right expr>. Example: |
|
| 241 | + * |
|
| 242 | + * [php] |
|
| 243 | + * // u.id >= ? |
|
| 244 | + * $q->where($q->expr()->gte('u.id', '?')); |
|
| 245 | + * |
|
| 246 | + * @param mixed $x The left expression. |
|
| 247 | + * @param mixed $y The right expression. |
|
| 248 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 249 | + * required when comparing text fields for oci compatibility |
|
| 250 | + * |
|
| 251 | + * @return string |
|
| 252 | + * @since 8.2.0 - Parameter $type was added in 9.0.0 |
|
| 253 | + * |
|
| 254 | + * @psalm-taint-sink sql $x |
|
| 255 | + * @psalm-taint-sink sql $y |
|
| 256 | + * @psalm-taint-sink sql $type |
|
| 257 | + */ |
|
| 258 | + public function gte($x, $y, $type = null): string; |
|
| 259 | 259 | |
| 260 | - /** |
|
| 261 | - * Creates an IS NULL expression with the given arguments. |
|
| 262 | - * |
|
| 263 | - * @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be restricted by IS NULL. |
|
| 264 | - * |
|
| 265 | - * @return string |
|
| 266 | - * @since 8.2.0 |
|
| 267 | - * |
|
| 268 | - * @psalm-taint-sink sql $x |
|
| 269 | - */ |
|
| 270 | - public function isNull($x): string; |
|
| 260 | + /** |
|
| 261 | + * Creates an IS NULL expression with the given arguments. |
|
| 262 | + * |
|
| 263 | + * @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be restricted by IS NULL. |
|
| 264 | + * |
|
| 265 | + * @return string |
|
| 266 | + * @since 8.2.0 |
|
| 267 | + * |
|
| 268 | + * @psalm-taint-sink sql $x |
|
| 269 | + */ |
|
| 270 | + public function isNull($x): string; |
|
| 271 | 271 | |
| 272 | - /** |
|
| 273 | - * Creates an IS NOT NULL expression with the given arguments. |
|
| 274 | - * |
|
| 275 | - * @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be restricted by IS NOT NULL. |
|
| 276 | - * |
|
| 277 | - * @return string |
|
| 278 | - * @since 8.2.0 |
|
| 279 | - * |
|
| 280 | - * @psalm-taint-sink sql $x |
|
| 281 | - */ |
|
| 282 | - public function isNotNull($x): string; |
|
| 272 | + /** |
|
| 273 | + * Creates an IS NOT NULL expression with the given arguments. |
|
| 274 | + * |
|
| 275 | + * @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be restricted by IS NOT NULL. |
|
| 276 | + * |
|
| 277 | + * @return string |
|
| 278 | + * @since 8.2.0 |
|
| 279 | + * |
|
| 280 | + * @psalm-taint-sink sql $x |
|
| 281 | + */ |
|
| 282 | + public function isNotNull($x): string; |
|
| 283 | 283 | |
| 284 | - /** |
|
| 285 | - * Creates a LIKE() comparison expression with the given arguments. |
|
| 286 | - * |
|
| 287 | - * @param ILiteral|IParameter|IQueryFunction|string $x Field in string format to be inspected by LIKE() comparison. |
|
| 288 | - * @param mixed $y Argument to be used in LIKE() comparison. |
|
| 289 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 290 | - * required when comparing text fields for oci compatibility |
|
| 291 | - * |
|
| 292 | - * @return string |
|
| 293 | - * @since 8.2.0 - Parameter $type was added in 9.0.0 |
|
| 294 | - * |
|
| 295 | - * @psalm-taint-sink sql $x |
|
| 296 | - * @psalm-taint-sink sql $y |
|
| 297 | - * @psalm-taint-sink sql $type |
|
| 298 | - */ |
|
| 299 | - public function like($x, $y, $type = null): string; |
|
| 284 | + /** |
|
| 285 | + * Creates a LIKE() comparison expression with the given arguments. |
|
| 286 | + * |
|
| 287 | + * @param ILiteral|IParameter|IQueryFunction|string $x Field in string format to be inspected by LIKE() comparison. |
|
| 288 | + * @param mixed $y Argument to be used in LIKE() comparison. |
|
| 289 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 290 | + * required when comparing text fields for oci compatibility |
|
| 291 | + * |
|
| 292 | + * @return string |
|
| 293 | + * @since 8.2.0 - Parameter $type was added in 9.0.0 |
|
| 294 | + * |
|
| 295 | + * @psalm-taint-sink sql $x |
|
| 296 | + * @psalm-taint-sink sql $y |
|
| 297 | + * @psalm-taint-sink sql $type |
|
| 298 | + */ |
|
| 299 | + public function like($x, $y, $type = null): string; |
|
| 300 | 300 | |
| 301 | - /** |
|
| 302 | - * Creates a NOT LIKE() comparison expression with the given arguments. |
|
| 303 | - * |
|
| 304 | - * @param ILiteral|IParameter|IQueryFunction|string $x Field in string format to be inspected by NOT LIKE() comparison. |
|
| 305 | - * @param mixed $y Argument to be used in NOT LIKE() comparison. |
|
| 306 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 307 | - * required when comparing text fields for oci compatibility |
|
| 308 | - * |
|
| 309 | - * @return string |
|
| 310 | - * @since 8.2.0 - Parameter $type was added in 9.0.0 |
|
| 311 | - * |
|
| 312 | - * @psalm-taint-sink sql $x |
|
| 313 | - * @psalm-taint-sink sql $y |
|
| 314 | - * @psalm-taint-sink sql $type |
|
| 315 | - */ |
|
| 316 | - public function notLike($x, $y, $type = null): string; |
|
| 301 | + /** |
|
| 302 | + * Creates a NOT LIKE() comparison expression with the given arguments. |
|
| 303 | + * |
|
| 304 | + * @param ILiteral|IParameter|IQueryFunction|string $x Field in string format to be inspected by NOT LIKE() comparison. |
|
| 305 | + * @param mixed $y Argument to be used in NOT LIKE() comparison. |
|
| 306 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 307 | + * required when comparing text fields for oci compatibility |
|
| 308 | + * |
|
| 309 | + * @return string |
|
| 310 | + * @since 8.2.0 - Parameter $type was added in 9.0.0 |
|
| 311 | + * |
|
| 312 | + * @psalm-taint-sink sql $x |
|
| 313 | + * @psalm-taint-sink sql $y |
|
| 314 | + * @psalm-taint-sink sql $type |
|
| 315 | + */ |
|
| 316 | + public function notLike($x, $y, $type = null): string; |
|
| 317 | 317 | |
| 318 | - /** |
|
| 319 | - * Creates a ILIKE() comparison expression with the given arguments. |
|
| 320 | - * |
|
| 321 | - * @param string $x Field in string format to be inspected by ILIKE() comparison. |
|
| 322 | - * @param mixed $y Argument to be used in ILIKE() comparison. |
|
| 323 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 324 | - * required when comparing text fields for oci compatibility |
|
| 325 | - * |
|
| 326 | - * @return string |
|
| 327 | - * @since 9.0.0 |
|
| 328 | - * |
|
| 329 | - * @psalm-taint-sink sql $x |
|
| 330 | - * @psalm-taint-sink sql $y |
|
| 331 | - * @psalm-taint-sink sql $type |
|
| 332 | - */ |
|
| 333 | - public function iLike($x, $y, $type = null): string; |
|
| 318 | + /** |
|
| 319 | + * Creates a ILIKE() comparison expression with the given arguments. |
|
| 320 | + * |
|
| 321 | + * @param string $x Field in string format to be inspected by ILIKE() comparison. |
|
| 322 | + * @param mixed $y Argument to be used in ILIKE() comparison. |
|
| 323 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 324 | + * required when comparing text fields for oci compatibility |
|
| 325 | + * |
|
| 326 | + * @return string |
|
| 327 | + * @since 9.0.0 |
|
| 328 | + * |
|
| 329 | + * @psalm-taint-sink sql $x |
|
| 330 | + * @psalm-taint-sink sql $y |
|
| 331 | + * @psalm-taint-sink sql $type |
|
| 332 | + */ |
|
| 333 | + public function iLike($x, $y, $type = null): string; |
|
| 334 | 334 | |
| 335 | - /** |
|
| 336 | - * Creates a IN () comparison expression with the given arguments. |
|
| 337 | - * |
|
| 338 | - * @param ILiteral|IParameter|IQueryFunction|string $x The field in string format to be inspected by IN() comparison. |
|
| 339 | - * @param ILiteral|IParameter|IQueryFunction|string|array $y The placeholder or the array of values to be used by IN() comparison. |
|
| 340 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 341 | - * required when comparing text fields for oci compatibility |
|
| 342 | - * |
|
| 343 | - * @return string |
|
| 344 | - * @since 8.2.0 - Parameter $type was added in 9.0.0 |
|
| 345 | - * |
|
| 346 | - * @psalm-taint-sink sql $x |
|
| 347 | - * @psalm-taint-sink sql $y |
|
| 348 | - * @psalm-taint-sink sql $type |
|
| 349 | - */ |
|
| 350 | - public function in($x, $y, $type = null): string; |
|
| 335 | + /** |
|
| 336 | + * Creates a IN () comparison expression with the given arguments. |
|
| 337 | + * |
|
| 338 | + * @param ILiteral|IParameter|IQueryFunction|string $x The field in string format to be inspected by IN() comparison. |
|
| 339 | + * @param ILiteral|IParameter|IQueryFunction|string|array $y The placeholder or the array of values to be used by IN() comparison. |
|
| 340 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 341 | + * required when comparing text fields for oci compatibility |
|
| 342 | + * |
|
| 343 | + * @return string |
|
| 344 | + * @since 8.2.0 - Parameter $type was added in 9.0.0 |
|
| 345 | + * |
|
| 346 | + * @psalm-taint-sink sql $x |
|
| 347 | + * @psalm-taint-sink sql $y |
|
| 348 | + * @psalm-taint-sink sql $type |
|
| 349 | + */ |
|
| 350 | + public function in($x, $y, $type = null): string; |
|
| 351 | 351 | |
| 352 | - /** |
|
| 353 | - * Creates a NOT IN () comparison expression with the given arguments. |
|
| 354 | - * |
|
| 355 | - * @param ILiteral|IParameter|IQueryFunction|string $x The field in string format to be inspected by NOT IN() comparison. |
|
| 356 | - * @param ILiteral|IParameter|IQueryFunction|string|array $y The placeholder or the array of values to be used by NOT IN() comparison. |
|
| 357 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 358 | - * required when comparing text fields for oci compatibility |
|
| 359 | - * |
|
| 360 | - * @return string |
|
| 361 | - * @since 8.2.0 - Parameter $type was added in 9.0.0 |
|
| 362 | - * |
|
| 363 | - * @psalm-taint-sink sql $x |
|
| 364 | - * @psalm-taint-sink sql $y |
|
| 365 | - * @psalm-taint-sink sql $type |
|
| 366 | - */ |
|
| 367 | - public function notIn($x, $y, $type = null): string; |
|
| 352 | + /** |
|
| 353 | + * Creates a NOT IN () comparison expression with the given arguments. |
|
| 354 | + * |
|
| 355 | + * @param ILiteral|IParameter|IQueryFunction|string $x The field in string format to be inspected by NOT IN() comparison. |
|
| 356 | + * @param ILiteral|IParameter|IQueryFunction|string|array $y The placeholder or the array of values to be used by NOT IN() comparison. |
|
| 357 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 358 | + * required when comparing text fields for oci compatibility |
|
| 359 | + * |
|
| 360 | + * @return string |
|
| 361 | + * @since 8.2.0 - Parameter $type was added in 9.0.0 |
|
| 362 | + * |
|
| 363 | + * @psalm-taint-sink sql $x |
|
| 364 | + * @psalm-taint-sink sql $y |
|
| 365 | + * @psalm-taint-sink sql $type |
|
| 366 | + */ |
|
| 367 | + public function notIn($x, $y, $type = null): string; |
|
| 368 | 368 | |
| 369 | - /** |
|
| 370 | - * Creates a $x = '' statement, because Oracle needs a different check |
|
| 371 | - * |
|
| 372 | - * @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be inspected by the comparison. |
|
| 373 | - * @return string |
|
| 374 | - * @since 13.0.0 |
|
| 375 | - * |
|
| 376 | - * @psalm-taint-sink sql $x |
|
| 377 | - */ |
|
| 378 | - public function emptyString($x): string; |
|
| 369 | + /** |
|
| 370 | + * Creates a $x = '' statement, because Oracle needs a different check |
|
| 371 | + * |
|
| 372 | + * @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be inspected by the comparison. |
|
| 373 | + * @return string |
|
| 374 | + * @since 13.0.0 |
|
| 375 | + * |
|
| 376 | + * @psalm-taint-sink sql $x |
|
| 377 | + */ |
|
| 378 | + public function emptyString($x): string; |
|
| 379 | 379 | |
| 380 | - /** |
|
| 381 | - * Creates a `$x <> ''` statement, because Oracle needs a different check |
|
| 382 | - * |
|
| 383 | - * @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be inspected by the comparison. |
|
| 384 | - * @return string |
|
| 385 | - * @since 13.0.0 |
|
| 386 | - * |
|
| 387 | - * @psalm-taint-sink sql $x |
|
| 388 | - */ |
|
| 389 | - public function nonEmptyString($x): string; |
|
| 380 | + /** |
|
| 381 | + * Creates a `$x <> ''` statement, because Oracle needs a different check |
|
| 382 | + * |
|
| 383 | + * @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be inspected by the comparison. |
|
| 384 | + * @return string |
|
| 385 | + * @since 13.0.0 |
|
| 386 | + * |
|
| 387 | + * @psalm-taint-sink sql $x |
|
| 388 | + */ |
|
| 389 | + public function nonEmptyString($x): string; |
|
| 390 | 390 | |
| 391 | 391 | |
| 392 | - /** |
|
| 393 | - * Creates a bitwise AND comparison |
|
| 394 | - * |
|
| 395 | - * @param string|ILiteral $x The field or value to check |
|
| 396 | - * @param int $y Bitmap that must be set |
|
| 397 | - * @return IQueryFunction |
|
| 398 | - * @since 12.0.0 |
|
| 399 | - * |
|
| 400 | - * @psalm-taint-sink sql $x |
|
| 401 | - * @psalm-taint-sink sql $y |
|
| 402 | - */ |
|
| 403 | - public function bitwiseAnd($x, int $y): IQueryFunction; |
|
| 392 | + /** |
|
| 393 | + * Creates a bitwise AND comparison |
|
| 394 | + * |
|
| 395 | + * @param string|ILiteral $x The field or value to check |
|
| 396 | + * @param int $y Bitmap that must be set |
|
| 397 | + * @return IQueryFunction |
|
| 398 | + * @since 12.0.0 |
|
| 399 | + * |
|
| 400 | + * @psalm-taint-sink sql $x |
|
| 401 | + * @psalm-taint-sink sql $y |
|
| 402 | + */ |
|
| 403 | + public function bitwiseAnd($x, int $y): IQueryFunction; |
|
| 404 | 404 | |
| 405 | - /** |
|
| 406 | - * Creates a bitwise OR comparison |
|
| 407 | - * |
|
| 408 | - * @param string|ILiteral $x The field or value to check |
|
| 409 | - * @param int $y Bitmap that must be set |
|
| 410 | - * @return IQueryFunction |
|
| 411 | - * @since 12.0.0 |
|
| 412 | - * |
|
| 413 | - * @psalm-taint-sink sql $x |
|
| 414 | - * @psalm-taint-sink sql $y |
|
| 415 | - */ |
|
| 416 | - public function bitwiseOr($x, int $y): IQueryFunction; |
|
| 405 | + /** |
|
| 406 | + * Creates a bitwise OR comparison |
|
| 407 | + * |
|
| 408 | + * @param string|ILiteral $x The field or value to check |
|
| 409 | + * @param int $y Bitmap that must be set |
|
| 410 | + * @return IQueryFunction |
|
| 411 | + * @since 12.0.0 |
|
| 412 | + * |
|
| 413 | + * @psalm-taint-sink sql $x |
|
| 414 | + * @psalm-taint-sink sql $y |
|
| 415 | + */ |
|
| 416 | + public function bitwiseOr($x, int $y): IQueryFunction; |
|
| 417 | 417 | |
| 418 | - /** |
|
| 419 | - * Quotes a given input parameter. |
|
| 420 | - * |
|
| 421 | - * @param mixed $input The parameter to be quoted. |
|
| 422 | - * @param mixed|null $type One of the IQueryBuilder::PARAM_* constants |
|
| 423 | - * |
|
| 424 | - * @return ILiteral |
|
| 425 | - * @since 8.2.0 |
|
| 426 | - * |
|
| 427 | - * @psalm-taint-sink sql $input |
|
| 428 | - * @psalm-taint-sink sql $type |
|
| 429 | - */ |
|
| 430 | - public function literal($input, $type = null): ILiteral; |
|
| 418 | + /** |
|
| 419 | + * Quotes a given input parameter. |
|
| 420 | + * |
|
| 421 | + * @param mixed $input The parameter to be quoted. |
|
| 422 | + * @param mixed|null $type One of the IQueryBuilder::PARAM_* constants |
|
| 423 | + * |
|
| 424 | + * @return ILiteral |
|
| 425 | + * @since 8.2.0 |
|
| 426 | + * |
|
| 427 | + * @psalm-taint-sink sql $input |
|
| 428 | + * @psalm-taint-sink sql $type |
|
| 429 | + */ |
|
| 430 | + public function literal($input, $type = null): ILiteral; |
|
| 431 | 431 | |
| 432 | - /** |
|
| 433 | - * Returns a IQueryFunction that casts the column to the given type |
|
| 434 | - * |
|
| 435 | - * @param string $column |
|
| 436 | - * @param mixed $type One of IQueryBuilder::PARAM_* |
|
| 437 | - * @return IQueryFunction |
|
| 438 | - * @since 9.0.0 |
|
| 439 | - * |
|
| 440 | - * @psalm-taint-sink sql $column |
|
| 441 | - * @psalm-taint-sink sql $type |
|
| 442 | - */ |
|
| 443 | - public function castColumn(string $column, $type): IQueryFunction; |
|
| 432 | + /** |
|
| 433 | + * Returns a IQueryFunction that casts the column to the given type |
|
| 434 | + * |
|
| 435 | + * @param string $column |
|
| 436 | + * @param mixed $type One of IQueryBuilder::PARAM_* |
|
| 437 | + * @return IQueryFunction |
|
| 438 | + * @since 9.0.0 |
|
| 439 | + * |
|
| 440 | + * @psalm-taint-sink sql $column |
|
| 441 | + * @psalm-taint-sink sql $type |
|
| 442 | + */ |
|
| 443 | + public function castColumn(string $column, $type): IQueryFunction; |
|
| 444 | 444 | } |
@@ -32,163 +32,163 @@ |
||
| 32 | 32 | |
| 33 | 33 | class OCIExpressionBuilder extends ExpressionBuilder { |
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * @param mixed $column |
|
| 37 | - * @param mixed|null $type |
|
| 38 | - * @return array|IQueryFunction|string |
|
| 39 | - */ |
|
| 40 | - protected function prepareColumn($column, $type) { |
|
| 41 | - if ($type === IQueryBuilder::PARAM_STR && !is_array($column) && !($column instanceof IParameter) && !($column instanceof ILiteral)) { |
|
| 42 | - $column = $this->castColumn($column, $type); |
|
| 43 | - } else { |
|
| 44 | - $column = $this->helper->quoteColumnNames($column); |
|
| 45 | - } |
|
| 46 | - return $column; |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * @inheritdoc |
|
| 51 | - */ |
|
| 52 | - public function comparison($x, string $operator, $y, $type = null): string { |
|
| 53 | - $x = $this->prepareColumn($x, $type); |
|
| 54 | - $y = $this->prepareColumn($y, $type); |
|
| 55 | - |
|
| 56 | - return $this->expressionBuilder->comparison($x, $operator, $y); |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * @inheritdoc |
|
| 61 | - */ |
|
| 62 | - public function eq($x, $y, $type = null): string { |
|
| 63 | - $x = $this->prepareColumn($x, $type); |
|
| 64 | - $y = $this->prepareColumn($y, $type); |
|
| 65 | - |
|
| 66 | - return $this->expressionBuilder->eq($x, $y); |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * @inheritdoc |
|
| 71 | - */ |
|
| 72 | - public function neq($x, $y, $type = null): string { |
|
| 73 | - $x = $this->prepareColumn($x, $type); |
|
| 74 | - $y = $this->prepareColumn($y, $type); |
|
| 75 | - |
|
| 76 | - return $this->expressionBuilder->neq($x, $y); |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * @inheritdoc |
|
| 81 | - */ |
|
| 82 | - public function lt($x, $y, $type = null): string { |
|
| 83 | - $x = $this->prepareColumn($x, $type); |
|
| 84 | - $y = $this->prepareColumn($y, $type); |
|
| 85 | - |
|
| 86 | - return $this->expressionBuilder->lt($x, $y); |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * @inheritdoc |
|
| 91 | - */ |
|
| 92 | - public function lte($x, $y, $type = null): string { |
|
| 93 | - $x = $this->prepareColumn($x, $type); |
|
| 94 | - $y = $this->prepareColumn($y, $type); |
|
| 95 | - |
|
| 96 | - return $this->expressionBuilder->lte($x, $y); |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - /** |
|
| 100 | - * @inheritdoc |
|
| 101 | - */ |
|
| 102 | - public function gt($x, $y, $type = null): string { |
|
| 103 | - $x = $this->prepareColumn($x, $type); |
|
| 104 | - $y = $this->prepareColumn($y, $type); |
|
| 105 | - |
|
| 106 | - return $this->expressionBuilder->gt($x, $y); |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - /** |
|
| 110 | - * @inheritdoc |
|
| 111 | - */ |
|
| 112 | - public function gte($x, $y, $type = null): string { |
|
| 113 | - $x = $this->prepareColumn($x, $type); |
|
| 114 | - $y = $this->prepareColumn($y, $type); |
|
| 115 | - |
|
| 116 | - return $this->expressionBuilder->gte($x, $y); |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - /** |
|
| 120 | - * @inheritdoc |
|
| 121 | - */ |
|
| 122 | - public function in($x, $y, $type = null): string { |
|
| 123 | - $x = $this->prepareColumn($x, $type); |
|
| 124 | - $y = $this->prepareColumn($y, $type); |
|
| 125 | - |
|
| 126 | - return $this->expressionBuilder->in($x, $y); |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - /** |
|
| 130 | - * @inheritdoc |
|
| 131 | - */ |
|
| 132 | - public function notIn($x, $y, $type = null): string { |
|
| 133 | - $x = $this->prepareColumn($x, $type); |
|
| 134 | - $y = $this->prepareColumn($y, $type); |
|
| 135 | - |
|
| 136 | - return $this->expressionBuilder->notIn($x, $y); |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - /** |
|
| 140 | - * Creates a $x = '' statement, because Oracle needs a different check |
|
| 141 | - * |
|
| 142 | - * @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be inspected by the comparison. |
|
| 143 | - * @return string |
|
| 144 | - * @since 13.0.0 |
|
| 145 | - */ |
|
| 146 | - public function emptyString($x): string { |
|
| 147 | - return $this->isNull($x); |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - /** |
|
| 151 | - * Creates a `$x <> ''` statement, because Oracle needs a different check |
|
| 152 | - * |
|
| 153 | - * @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be inspected by the comparison. |
|
| 154 | - * @return string |
|
| 155 | - * @since 13.0.0 |
|
| 156 | - */ |
|
| 157 | - public function nonEmptyString($x): string { |
|
| 158 | - return $this->isNotNull($x); |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - /** |
|
| 162 | - * Returns a IQueryFunction that casts the column to the given type |
|
| 163 | - * |
|
| 164 | - * @param string $column |
|
| 165 | - * @param mixed $type One of IQueryBuilder::PARAM_* |
|
| 166 | - * @return IQueryFunction |
|
| 167 | - */ |
|
| 168 | - public function castColumn(string $column, $type): IQueryFunction { |
|
| 169 | - if ($type === IQueryBuilder::PARAM_STR) { |
|
| 170 | - $column = $this->helper->quoteColumnName($column); |
|
| 171 | - return new QueryFunction('to_char(' . $column . ')'); |
|
| 172 | - } |
|
| 173 | - if ($type === IQueryBuilder::PARAM_INT) { |
|
| 174 | - $column = $this->helper->quoteColumnName($column); |
|
| 175 | - return new QueryFunction('to_number(to_char(' . $column . '))'); |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - return parent::castColumn($column, $type); |
|
| 179 | - } |
|
| 180 | - |
|
| 181 | - /** |
|
| 182 | - * @inheritdoc |
|
| 183 | - */ |
|
| 184 | - public function like($x, $y, $type = null): string { |
|
| 185 | - return parent::like($x, $y, $type) . " ESCAPE '\\'"; |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - /** |
|
| 189 | - * @inheritdoc |
|
| 190 | - */ |
|
| 191 | - public function iLike($x, $y, $type = null): string { |
|
| 192 | - return $this->like($this->functionBuilder->lower($x), $this->functionBuilder->lower($y)); |
|
| 193 | - } |
|
| 35 | + /** |
|
| 36 | + * @param mixed $column |
|
| 37 | + * @param mixed|null $type |
|
| 38 | + * @return array|IQueryFunction|string |
|
| 39 | + */ |
|
| 40 | + protected function prepareColumn($column, $type) { |
|
| 41 | + if ($type === IQueryBuilder::PARAM_STR && !is_array($column) && !($column instanceof IParameter) && !($column instanceof ILiteral)) { |
|
| 42 | + $column = $this->castColumn($column, $type); |
|
| 43 | + } else { |
|
| 44 | + $column = $this->helper->quoteColumnNames($column); |
|
| 45 | + } |
|
| 46 | + return $column; |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * @inheritdoc |
|
| 51 | + */ |
|
| 52 | + public function comparison($x, string $operator, $y, $type = null): string { |
|
| 53 | + $x = $this->prepareColumn($x, $type); |
|
| 54 | + $y = $this->prepareColumn($y, $type); |
|
| 55 | + |
|
| 56 | + return $this->expressionBuilder->comparison($x, $operator, $y); |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * @inheritdoc |
|
| 61 | + */ |
|
| 62 | + public function eq($x, $y, $type = null): string { |
|
| 63 | + $x = $this->prepareColumn($x, $type); |
|
| 64 | + $y = $this->prepareColumn($y, $type); |
|
| 65 | + |
|
| 66 | + return $this->expressionBuilder->eq($x, $y); |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * @inheritdoc |
|
| 71 | + */ |
|
| 72 | + public function neq($x, $y, $type = null): string { |
|
| 73 | + $x = $this->prepareColumn($x, $type); |
|
| 74 | + $y = $this->prepareColumn($y, $type); |
|
| 75 | + |
|
| 76 | + return $this->expressionBuilder->neq($x, $y); |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * @inheritdoc |
|
| 81 | + */ |
|
| 82 | + public function lt($x, $y, $type = null): string { |
|
| 83 | + $x = $this->prepareColumn($x, $type); |
|
| 84 | + $y = $this->prepareColumn($y, $type); |
|
| 85 | + |
|
| 86 | + return $this->expressionBuilder->lt($x, $y); |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * @inheritdoc |
|
| 91 | + */ |
|
| 92 | + public function lte($x, $y, $type = null): string { |
|
| 93 | + $x = $this->prepareColumn($x, $type); |
|
| 94 | + $y = $this->prepareColumn($y, $type); |
|
| 95 | + |
|
| 96 | + return $this->expressionBuilder->lte($x, $y); |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + /** |
|
| 100 | + * @inheritdoc |
|
| 101 | + */ |
|
| 102 | + public function gt($x, $y, $type = null): string { |
|
| 103 | + $x = $this->prepareColumn($x, $type); |
|
| 104 | + $y = $this->prepareColumn($y, $type); |
|
| 105 | + |
|
| 106 | + return $this->expressionBuilder->gt($x, $y); |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + /** |
|
| 110 | + * @inheritdoc |
|
| 111 | + */ |
|
| 112 | + public function gte($x, $y, $type = null): string { |
|
| 113 | + $x = $this->prepareColumn($x, $type); |
|
| 114 | + $y = $this->prepareColumn($y, $type); |
|
| 115 | + |
|
| 116 | + return $this->expressionBuilder->gte($x, $y); |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + /** |
|
| 120 | + * @inheritdoc |
|
| 121 | + */ |
|
| 122 | + public function in($x, $y, $type = null): string { |
|
| 123 | + $x = $this->prepareColumn($x, $type); |
|
| 124 | + $y = $this->prepareColumn($y, $type); |
|
| 125 | + |
|
| 126 | + return $this->expressionBuilder->in($x, $y); |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + /** |
|
| 130 | + * @inheritdoc |
|
| 131 | + */ |
|
| 132 | + public function notIn($x, $y, $type = null): string { |
|
| 133 | + $x = $this->prepareColumn($x, $type); |
|
| 134 | + $y = $this->prepareColumn($y, $type); |
|
| 135 | + |
|
| 136 | + return $this->expressionBuilder->notIn($x, $y); |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + /** |
|
| 140 | + * Creates a $x = '' statement, because Oracle needs a different check |
|
| 141 | + * |
|
| 142 | + * @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be inspected by the comparison. |
|
| 143 | + * @return string |
|
| 144 | + * @since 13.0.0 |
|
| 145 | + */ |
|
| 146 | + public function emptyString($x): string { |
|
| 147 | + return $this->isNull($x); |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + /** |
|
| 151 | + * Creates a `$x <> ''` statement, because Oracle needs a different check |
|
| 152 | + * |
|
| 153 | + * @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be inspected by the comparison. |
|
| 154 | + * @return string |
|
| 155 | + * @since 13.0.0 |
|
| 156 | + */ |
|
| 157 | + public function nonEmptyString($x): string { |
|
| 158 | + return $this->isNotNull($x); |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + /** |
|
| 162 | + * Returns a IQueryFunction that casts the column to the given type |
|
| 163 | + * |
|
| 164 | + * @param string $column |
|
| 165 | + * @param mixed $type One of IQueryBuilder::PARAM_* |
|
| 166 | + * @return IQueryFunction |
|
| 167 | + */ |
|
| 168 | + public function castColumn(string $column, $type): IQueryFunction { |
|
| 169 | + if ($type === IQueryBuilder::PARAM_STR) { |
|
| 170 | + $column = $this->helper->quoteColumnName($column); |
|
| 171 | + return new QueryFunction('to_char(' . $column . ')'); |
|
| 172 | + } |
|
| 173 | + if ($type === IQueryBuilder::PARAM_INT) { |
|
| 174 | + $column = $this->helper->quoteColumnName($column); |
|
| 175 | + return new QueryFunction('to_number(to_char(' . $column . '))'); |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + return parent::castColumn($column, $type); |
|
| 179 | + } |
|
| 180 | + |
|
| 181 | + /** |
|
| 182 | + * @inheritdoc |
|
| 183 | + */ |
|
| 184 | + public function like($x, $y, $type = null): string { |
|
| 185 | + return parent::like($x, $y, $type) . " ESCAPE '\\'"; |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + /** |
|
| 189 | + * @inheritdoc |
|
| 190 | + */ |
|
| 191 | + public function iLike($x, $y, $type = null): string { |
|
| 192 | + return $this->like($this->functionBuilder->lower($x), $this->functionBuilder->lower($y)); |
|
| 193 | + } |
|
| 194 | 194 | } |
@@ -168,11 +168,11 @@ discard block |
||
| 168 | 168 | public function castColumn(string $column, $type): IQueryFunction { |
| 169 | 169 | if ($type === IQueryBuilder::PARAM_STR) { |
| 170 | 170 | $column = $this->helper->quoteColumnName($column); |
| 171 | - return new QueryFunction('to_char(' . $column . ')'); |
|
| 171 | + return new QueryFunction('to_char('.$column.')'); |
|
| 172 | 172 | } |
| 173 | 173 | if ($type === IQueryBuilder::PARAM_INT) { |
| 174 | 174 | $column = $this->helper->quoteColumnName($column); |
| 175 | - return new QueryFunction('to_number(to_char(' . $column . '))'); |
|
| 175 | + return new QueryFunction('to_number(to_char('.$column.'))'); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | return parent::castColumn($column, $type); |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | * @inheritdoc |
| 183 | 183 | */ |
| 184 | 184 | public function like($x, $y, $type = null): string { |
| 185 | - return parent::like($x, $y, $type) . " ESCAPE '\\'"; |
|
| 185 | + return parent::like($x, $y, $type)." ESCAPE '\\'"; |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | /** |
@@ -42,396 +42,396 @@ |
||
| 42 | 42 | use OCP\IDBConnection; |
| 43 | 43 | |
| 44 | 44 | class ExpressionBuilder implements IExpressionBuilder { |
| 45 | - /** @var \Doctrine\DBAL\Query\Expression\ExpressionBuilder */ |
|
| 46 | - protected $expressionBuilder; |
|
| 45 | + /** @var \Doctrine\DBAL\Query\Expression\ExpressionBuilder */ |
|
| 46 | + protected $expressionBuilder; |
|
| 47 | 47 | |
| 48 | - /** @var QuoteHelper */ |
|
| 49 | - protected $helper; |
|
| 48 | + /** @var QuoteHelper */ |
|
| 49 | + protected $helper; |
|
| 50 | 50 | |
| 51 | - /** @var IDBConnection */ |
|
| 52 | - protected $connection; |
|
| 51 | + /** @var IDBConnection */ |
|
| 52 | + protected $connection; |
|
| 53 | 53 | |
| 54 | - /** @var FunctionBuilder */ |
|
| 55 | - protected $functionBuilder; |
|
| 54 | + /** @var FunctionBuilder */ |
|
| 55 | + protected $functionBuilder; |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * Initializes a new <tt>ExpressionBuilder</tt>. |
|
| 59 | - * |
|
| 60 | - * @param ConnectionAdapter $connection |
|
| 61 | - * @param IQueryBuilder $queryBuilder |
|
| 62 | - */ |
|
| 63 | - public function __construct(ConnectionAdapter $connection, IQueryBuilder $queryBuilder) { |
|
| 64 | - $this->connection = $connection; |
|
| 65 | - $this->helper = new QuoteHelper(); |
|
| 66 | - $this->expressionBuilder = new DoctrineExpressionBuilder($connection->getInner()); |
|
| 67 | - $this->functionBuilder = $queryBuilder->func(); |
|
| 68 | - } |
|
| 57 | + /** |
|
| 58 | + * Initializes a new <tt>ExpressionBuilder</tt>. |
|
| 59 | + * |
|
| 60 | + * @param ConnectionAdapter $connection |
|
| 61 | + * @param IQueryBuilder $queryBuilder |
|
| 62 | + */ |
|
| 63 | + public function __construct(ConnectionAdapter $connection, IQueryBuilder $queryBuilder) { |
|
| 64 | + $this->connection = $connection; |
|
| 65 | + $this->helper = new QuoteHelper(); |
|
| 66 | + $this->expressionBuilder = new DoctrineExpressionBuilder($connection->getInner()); |
|
| 67 | + $this->functionBuilder = $queryBuilder->func(); |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * Creates a conjunction of the given boolean expressions. |
|
| 72 | - * |
|
| 73 | - * Example: |
|
| 74 | - * |
|
| 75 | - * [php] |
|
| 76 | - * // (u.type = ?) AND (u.role = ?) |
|
| 77 | - * $expr->andX('u.type = ?', 'u.role = ?')); |
|
| 78 | - * |
|
| 79 | - * @param mixed ...$x Optional clause. Defaults = null, but requires |
|
| 80 | - * at least one defined when converting to string. |
|
| 81 | - * |
|
| 82 | - * @return \OCP\DB\QueryBuilder\ICompositeExpression |
|
| 83 | - */ |
|
| 84 | - public function andX(...$x): ICompositeExpression { |
|
| 85 | - $compositeExpression = call_user_func_array([$this->expressionBuilder, 'andX'], $x); |
|
| 86 | - return new CompositeExpression($compositeExpression); |
|
| 87 | - } |
|
| 70 | + /** |
|
| 71 | + * Creates a conjunction of the given boolean expressions. |
|
| 72 | + * |
|
| 73 | + * Example: |
|
| 74 | + * |
|
| 75 | + * [php] |
|
| 76 | + * // (u.type = ?) AND (u.role = ?) |
|
| 77 | + * $expr->andX('u.type = ?', 'u.role = ?')); |
|
| 78 | + * |
|
| 79 | + * @param mixed ...$x Optional clause. Defaults = null, but requires |
|
| 80 | + * at least one defined when converting to string. |
|
| 81 | + * |
|
| 82 | + * @return \OCP\DB\QueryBuilder\ICompositeExpression |
|
| 83 | + */ |
|
| 84 | + public function andX(...$x): ICompositeExpression { |
|
| 85 | + $compositeExpression = call_user_func_array([$this->expressionBuilder, 'andX'], $x); |
|
| 86 | + return new CompositeExpression($compositeExpression); |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - /** |
|
| 90 | - * Creates a disjunction of the given boolean expressions. |
|
| 91 | - * |
|
| 92 | - * Example: |
|
| 93 | - * |
|
| 94 | - * [php] |
|
| 95 | - * // (u.type = ?) OR (u.role = ?) |
|
| 96 | - * $qb->where($qb->expr()->orX('u.type = ?', 'u.role = ?')); |
|
| 97 | - * |
|
| 98 | - * @param mixed ...$x Optional clause. Defaults = null, but requires |
|
| 99 | - * at least one defined when converting to string. |
|
| 100 | - * |
|
| 101 | - * @return \OCP\DB\QueryBuilder\ICompositeExpression |
|
| 102 | - */ |
|
| 103 | - public function orX(...$x): ICompositeExpression { |
|
| 104 | - $compositeExpression = call_user_func_array([$this->expressionBuilder, 'orX'], $x); |
|
| 105 | - return new CompositeExpression($compositeExpression); |
|
| 106 | - } |
|
| 89 | + /** |
|
| 90 | + * Creates a disjunction of the given boolean expressions. |
|
| 91 | + * |
|
| 92 | + * Example: |
|
| 93 | + * |
|
| 94 | + * [php] |
|
| 95 | + * // (u.type = ?) OR (u.role = ?) |
|
| 96 | + * $qb->where($qb->expr()->orX('u.type = ?', 'u.role = ?')); |
|
| 97 | + * |
|
| 98 | + * @param mixed ...$x Optional clause. Defaults = null, but requires |
|
| 99 | + * at least one defined when converting to string. |
|
| 100 | + * |
|
| 101 | + * @return \OCP\DB\QueryBuilder\ICompositeExpression |
|
| 102 | + */ |
|
| 103 | + public function orX(...$x): ICompositeExpression { |
|
| 104 | + $compositeExpression = call_user_func_array([$this->expressionBuilder, 'orX'], $x); |
|
| 105 | + return new CompositeExpression($compositeExpression); |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | - /** |
|
| 109 | - * Creates a comparison expression. |
|
| 110 | - * |
|
| 111 | - * @param mixed $x The left expression. |
|
| 112 | - * @param string $operator One of the IExpressionBuilder::* constants. |
|
| 113 | - * @param mixed $y The right expression. |
|
| 114 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 115 | - * required when comparing text fields for oci compatibility |
|
| 116 | - * |
|
| 117 | - * @return string |
|
| 118 | - */ |
|
| 119 | - public function comparison($x, string $operator, $y, $type = null): string { |
|
| 120 | - $x = $this->helper->quoteColumnName($x); |
|
| 121 | - $y = $this->helper->quoteColumnName($y); |
|
| 122 | - return $this->expressionBuilder->comparison($x, $operator, $y); |
|
| 123 | - } |
|
| 108 | + /** |
|
| 109 | + * Creates a comparison expression. |
|
| 110 | + * |
|
| 111 | + * @param mixed $x The left expression. |
|
| 112 | + * @param string $operator One of the IExpressionBuilder::* constants. |
|
| 113 | + * @param mixed $y The right expression. |
|
| 114 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 115 | + * required when comparing text fields for oci compatibility |
|
| 116 | + * |
|
| 117 | + * @return string |
|
| 118 | + */ |
|
| 119 | + public function comparison($x, string $operator, $y, $type = null): string { |
|
| 120 | + $x = $this->helper->quoteColumnName($x); |
|
| 121 | + $y = $this->helper->quoteColumnName($y); |
|
| 122 | + return $this->expressionBuilder->comparison($x, $operator, $y); |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | - /** |
|
| 126 | - * Creates an equality comparison expression with the given arguments. |
|
| 127 | - * |
|
| 128 | - * First argument is considered the left expression and the second is the right expression. |
|
| 129 | - * When converted to string, it will generated a <left expr> = <right expr>. Example: |
|
| 130 | - * |
|
| 131 | - * [php] |
|
| 132 | - * // u.id = ? |
|
| 133 | - * $expr->eq('u.id', '?'); |
|
| 134 | - * |
|
| 135 | - * @param mixed $x The left expression. |
|
| 136 | - * @param mixed $y The right expression. |
|
| 137 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 138 | - * required when comparing text fields for oci compatibility |
|
| 139 | - * |
|
| 140 | - * @return string |
|
| 141 | - */ |
|
| 142 | - public function eq($x, $y, $type = null): string { |
|
| 143 | - $x = $this->helper->quoteColumnName($x); |
|
| 144 | - $y = $this->helper->quoteColumnName($y); |
|
| 145 | - return $this->expressionBuilder->eq($x, $y); |
|
| 146 | - } |
|
| 125 | + /** |
|
| 126 | + * Creates an equality comparison expression with the given arguments. |
|
| 127 | + * |
|
| 128 | + * First argument is considered the left expression and the second is the right expression. |
|
| 129 | + * When converted to string, it will generated a <left expr> = <right expr>. Example: |
|
| 130 | + * |
|
| 131 | + * [php] |
|
| 132 | + * // u.id = ? |
|
| 133 | + * $expr->eq('u.id', '?'); |
|
| 134 | + * |
|
| 135 | + * @param mixed $x The left expression. |
|
| 136 | + * @param mixed $y The right expression. |
|
| 137 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 138 | + * required when comparing text fields for oci compatibility |
|
| 139 | + * |
|
| 140 | + * @return string |
|
| 141 | + */ |
|
| 142 | + public function eq($x, $y, $type = null): string { |
|
| 143 | + $x = $this->helper->quoteColumnName($x); |
|
| 144 | + $y = $this->helper->quoteColumnName($y); |
|
| 145 | + return $this->expressionBuilder->eq($x, $y); |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | - /** |
|
| 149 | - * Creates a non equality comparison expression with the given arguments. |
|
| 150 | - * First argument is considered the left expression and the second is the right expression. |
|
| 151 | - * When converted to string, it will generated a <left expr> <> <right expr>. Example: |
|
| 152 | - * |
|
| 153 | - * [php] |
|
| 154 | - * // u.id <> 1 |
|
| 155 | - * $q->where($q->expr()->neq('u.id', '1')); |
|
| 156 | - * |
|
| 157 | - * @param mixed $x The left expression. |
|
| 158 | - * @param mixed $y The right expression. |
|
| 159 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 160 | - * required when comparing text fields for oci compatibility |
|
| 161 | - * |
|
| 162 | - * @return string |
|
| 163 | - */ |
|
| 164 | - public function neq($x, $y, $type = null): string { |
|
| 165 | - $x = $this->helper->quoteColumnName($x); |
|
| 166 | - $y = $this->helper->quoteColumnName($y); |
|
| 167 | - return $this->expressionBuilder->neq($x, $y); |
|
| 168 | - } |
|
| 148 | + /** |
|
| 149 | + * Creates a non equality comparison expression with the given arguments. |
|
| 150 | + * First argument is considered the left expression and the second is the right expression. |
|
| 151 | + * When converted to string, it will generated a <left expr> <> <right expr>. Example: |
|
| 152 | + * |
|
| 153 | + * [php] |
|
| 154 | + * // u.id <> 1 |
|
| 155 | + * $q->where($q->expr()->neq('u.id', '1')); |
|
| 156 | + * |
|
| 157 | + * @param mixed $x The left expression. |
|
| 158 | + * @param mixed $y The right expression. |
|
| 159 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 160 | + * required when comparing text fields for oci compatibility |
|
| 161 | + * |
|
| 162 | + * @return string |
|
| 163 | + */ |
|
| 164 | + public function neq($x, $y, $type = null): string { |
|
| 165 | + $x = $this->helper->quoteColumnName($x); |
|
| 166 | + $y = $this->helper->quoteColumnName($y); |
|
| 167 | + return $this->expressionBuilder->neq($x, $y); |
|
| 168 | + } |
|
| 169 | 169 | |
| 170 | - /** |
|
| 171 | - * Creates a lower-than comparison expression with the given arguments. |
|
| 172 | - * First argument is considered the left expression and the second is the right expression. |
|
| 173 | - * When converted to string, it will generated a <left expr> < <right expr>. Example: |
|
| 174 | - * |
|
| 175 | - * [php] |
|
| 176 | - * // u.id < ? |
|
| 177 | - * $q->where($q->expr()->lt('u.id', '?')); |
|
| 178 | - * |
|
| 179 | - * @param mixed $x The left expression. |
|
| 180 | - * @param mixed $y The right expression. |
|
| 181 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 182 | - * required when comparing text fields for oci compatibility |
|
| 183 | - * |
|
| 184 | - * @return string |
|
| 185 | - */ |
|
| 186 | - public function lt($x, $y, $type = null): string { |
|
| 187 | - $x = $this->helper->quoteColumnName($x); |
|
| 188 | - $y = $this->helper->quoteColumnName($y); |
|
| 189 | - return $this->expressionBuilder->lt($x, $y); |
|
| 190 | - } |
|
| 170 | + /** |
|
| 171 | + * Creates a lower-than comparison expression with the given arguments. |
|
| 172 | + * First argument is considered the left expression and the second is the right expression. |
|
| 173 | + * When converted to string, it will generated a <left expr> < <right expr>. Example: |
|
| 174 | + * |
|
| 175 | + * [php] |
|
| 176 | + * // u.id < ? |
|
| 177 | + * $q->where($q->expr()->lt('u.id', '?')); |
|
| 178 | + * |
|
| 179 | + * @param mixed $x The left expression. |
|
| 180 | + * @param mixed $y The right expression. |
|
| 181 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 182 | + * required when comparing text fields for oci compatibility |
|
| 183 | + * |
|
| 184 | + * @return string |
|
| 185 | + */ |
|
| 186 | + public function lt($x, $y, $type = null): string { |
|
| 187 | + $x = $this->helper->quoteColumnName($x); |
|
| 188 | + $y = $this->helper->quoteColumnName($y); |
|
| 189 | + return $this->expressionBuilder->lt($x, $y); |
|
| 190 | + } |
|
| 191 | 191 | |
| 192 | - /** |
|
| 193 | - * Creates a lower-than-equal comparison expression with the given arguments. |
|
| 194 | - * First argument is considered the left expression and the second is the right expression. |
|
| 195 | - * When converted to string, it will generated a <left expr> <= <right expr>. Example: |
|
| 196 | - * |
|
| 197 | - * [php] |
|
| 198 | - * // u.id <= ? |
|
| 199 | - * $q->where($q->expr()->lte('u.id', '?')); |
|
| 200 | - * |
|
| 201 | - * @param mixed $x The left expression. |
|
| 202 | - * @param mixed $y The right expression. |
|
| 203 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 204 | - * required when comparing text fields for oci compatibility |
|
| 205 | - * |
|
| 206 | - * @return string |
|
| 207 | - */ |
|
| 208 | - public function lte($x, $y, $type = null): string { |
|
| 209 | - $x = $this->helper->quoteColumnName($x); |
|
| 210 | - $y = $this->helper->quoteColumnName($y); |
|
| 211 | - return $this->expressionBuilder->lte($x, $y); |
|
| 212 | - } |
|
| 192 | + /** |
|
| 193 | + * Creates a lower-than-equal comparison expression with the given arguments. |
|
| 194 | + * First argument is considered the left expression and the second is the right expression. |
|
| 195 | + * When converted to string, it will generated a <left expr> <= <right expr>. Example: |
|
| 196 | + * |
|
| 197 | + * [php] |
|
| 198 | + * // u.id <= ? |
|
| 199 | + * $q->where($q->expr()->lte('u.id', '?')); |
|
| 200 | + * |
|
| 201 | + * @param mixed $x The left expression. |
|
| 202 | + * @param mixed $y The right expression. |
|
| 203 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 204 | + * required when comparing text fields for oci compatibility |
|
| 205 | + * |
|
| 206 | + * @return string |
|
| 207 | + */ |
|
| 208 | + public function lte($x, $y, $type = null): string { |
|
| 209 | + $x = $this->helper->quoteColumnName($x); |
|
| 210 | + $y = $this->helper->quoteColumnName($y); |
|
| 211 | + return $this->expressionBuilder->lte($x, $y); |
|
| 212 | + } |
|
| 213 | 213 | |
| 214 | - /** |
|
| 215 | - * Creates a greater-than comparison expression with the given arguments. |
|
| 216 | - * First argument is considered the left expression and the second is the right expression. |
|
| 217 | - * When converted to string, it will generated a <left expr> > <right expr>. Example: |
|
| 218 | - * |
|
| 219 | - * [php] |
|
| 220 | - * // u.id > ? |
|
| 221 | - * $q->where($q->expr()->gt('u.id', '?')); |
|
| 222 | - * |
|
| 223 | - * @param mixed $x The left expression. |
|
| 224 | - * @param mixed $y The right expression. |
|
| 225 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 226 | - * required when comparing text fields for oci compatibility |
|
| 227 | - * |
|
| 228 | - * @return string |
|
| 229 | - */ |
|
| 230 | - public function gt($x, $y, $type = null): string { |
|
| 231 | - $x = $this->helper->quoteColumnName($x); |
|
| 232 | - $y = $this->helper->quoteColumnName($y); |
|
| 233 | - return $this->expressionBuilder->gt($x, $y); |
|
| 234 | - } |
|
| 214 | + /** |
|
| 215 | + * Creates a greater-than comparison expression with the given arguments. |
|
| 216 | + * First argument is considered the left expression and the second is the right expression. |
|
| 217 | + * When converted to string, it will generated a <left expr> > <right expr>. Example: |
|
| 218 | + * |
|
| 219 | + * [php] |
|
| 220 | + * // u.id > ? |
|
| 221 | + * $q->where($q->expr()->gt('u.id', '?')); |
|
| 222 | + * |
|
| 223 | + * @param mixed $x The left expression. |
|
| 224 | + * @param mixed $y The right expression. |
|
| 225 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 226 | + * required when comparing text fields for oci compatibility |
|
| 227 | + * |
|
| 228 | + * @return string |
|
| 229 | + */ |
|
| 230 | + public function gt($x, $y, $type = null): string { |
|
| 231 | + $x = $this->helper->quoteColumnName($x); |
|
| 232 | + $y = $this->helper->quoteColumnName($y); |
|
| 233 | + return $this->expressionBuilder->gt($x, $y); |
|
| 234 | + } |
|
| 235 | 235 | |
| 236 | - /** |
|
| 237 | - * Creates a greater-than-equal comparison expression with the given arguments. |
|
| 238 | - * First argument is considered the left expression and the second is the right expression. |
|
| 239 | - * When converted to string, it will generated a <left expr> >= <right expr>. Example: |
|
| 240 | - * |
|
| 241 | - * [php] |
|
| 242 | - * // u.id >= ? |
|
| 243 | - * $q->where($q->expr()->gte('u.id', '?')); |
|
| 244 | - * |
|
| 245 | - * @param mixed $x The left expression. |
|
| 246 | - * @param mixed $y The right expression. |
|
| 247 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 248 | - * required when comparing text fields for oci compatibility |
|
| 249 | - * |
|
| 250 | - * @return string |
|
| 251 | - */ |
|
| 252 | - public function gte($x, $y, $type = null): string { |
|
| 253 | - $x = $this->helper->quoteColumnName($x); |
|
| 254 | - $y = $this->helper->quoteColumnName($y); |
|
| 255 | - return $this->expressionBuilder->gte($x, $y); |
|
| 256 | - } |
|
| 236 | + /** |
|
| 237 | + * Creates a greater-than-equal comparison expression with the given arguments. |
|
| 238 | + * First argument is considered the left expression and the second is the right expression. |
|
| 239 | + * When converted to string, it will generated a <left expr> >= <right expr>. Example: |
|
| 240 | + * |
|
| 241 | + * [php] |
|
| 242 | + * // u.id >= ? |
|
| 243 | + * $q->where($q->expr()->gte('u.id', '?')); |
|
| 244 | + * |
|
| 245 | + * @param mixed $x The left expression. |
|
| 246 | + * @param mixed $y The right expression. |
|
| 247 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 248 | + * required when comparing text fields for oci compatibility |
|
| 249 | + * |
|
| 250 | + * @return string |
|
| 251 | + */ |
|
| 252 | + public function gte($x, $y, $type = null): string { |
|
| 253 | + $x = $this->helper->quoteColumnName($x); |
|
| 254 | + $y = $this->helper->quoteColumnName($y); |
|
| 255 | + return $this->expressionBuilder->gte($x, $y); |
|
| 256 | + } |
|
| 257 | 257 | |
| 258 | - /** |
|
| 259 | - * Creates an IS NULL expression with the given arguments. |
|
| 260 | - * |
|
| 261 | - * @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be restricted by IS NULL. |
|
| 262 | - * |
|
| 263 | - * @return string |
|
| 264 | - */ |
|
| 265 | - public function isNull($x): string { |
|
| 266 | - $x = $this->helper->quoteColumnName($x); |
|
| 267 | - return $this->expressionBuilder->isNull($x); |
|
| 268 | - } |
|
| 258 | + /** |
|
| 259 | + * Creates an IS NULL expression with the given arguments. |
|
| 260 | + * |
|
| 261 | + * @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be restricted by IS NULL. |
|
| 262 | + * |
|
| 263 | + * @return string |
|
| 264 | + */ |
|
| 265 | + public function isNull($x): string { |
|
| 266 | + $x = $this->helper->quoteColumnName($x); |
|
| 267 | + return $this->expressionBuilder->isNull($x); |
|
| 268 | + } |
|
| 269 | 269 | |
| 270 | - /** |
|
| 271 | - * Creates an IS NOT NULL expression with the given arguments. |
|
| 272 | - * |
|
| 273 | - * @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be restricted by IS NOT NULL. |
|
| 274 | - * |
|
| 275 | - * @return string |
|
| 276 | - */ |
|
| 277 | - public function isNotNull($x): string { |
|
| 278 | - $x = $this->helper->quoteColumnName($x); |
|
| 279 | - return $this->expressionBuilder->isNotNull($x); |
|
| 280 | - } |
|
| 270 | + /** |
|
| 271 | + * Creates an IS NOT NULL expression with the given arguments. |
|
| 272 | + * |
|
| 273 | + * @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be restricted by IS NOT NULL. |
|
| 274 | + * |
|
| 275 | + * @return string |
|
| 276 | + */ |
|
| 277 | + public function isNotNull($x): string { |
|
| 278 | + $x = $this->helper->quoteColumnName($x); |
|
| 279 | + return $this->expressionBuilder->isNotNull($x); |
|
| 280 | + } |
|
| 281 | 281 | |
| 282 | - /** |
|
| 283 | - * Creates a LIKE() comparison expression with the given arguments. |
|
| 284 | - * |
|
| 285 | - * @param ILiteral|IParameter|IQueryFunction|string $x Field in string format to be inspected by LIKE() comparison. |
|
| 286 | - * @param mixed $y Argument to be used in LIKE() comparison. |
|
| 287 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 288 | - * required when comparing text fields for oci compatibility |
|
| 289 | - * |
|
| 290 | - * @return string |
|
| 291 | - */ |
|
| 292 | - public function like($x, $y, $type = null): string { |
|
| 293 | - $x = $this->helper->quoteColumnName($x); |
|
| 294 | - $y = $this->helper->quoteColumnName($y); |
|
| 295 | - return $this->expressionBuilder->like($x, $y); |
|
| 296 | - } |
|
| 282 | + /** |
|
| 283 | + * Creates a LIKE() comparison expression with the given arguments. |
|
| 284 | + * |
|
| 285 | + * @param ILiteral|IParameter|IQueryFunction|string $x Field in string format to be inspected by LIKE() comparison. |
|
| 286 | + * @param mixed $y Argument to be used in LIKE() comparison. |
|
| 287 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 288 | + * required when comparing text fields for oci compatibility |
|
| 289 | + * |
|
| 290 | + * @return string |
|
| 291 | + */ |
|
| 292 | + public function like($x, $y, $type = null): string { |
|
| 293 | + $x = $this->helper->quoteColumnName($x); |
|
| 294 | + $y = $this->helper->quoteColumnName($y); |
|
| 295 | + return $this->expressionBuilder->like($x, $y); |
|
| 296 | + } |
|
| 297 | 297 | |
| 298 | - /** |
|
| 299 | - * Creates a ILIKE() comparison expression with the given arguments. |
|
| 300 | - * |
|
| 301 | - * @param string $x Field in string format to be inspected by ILIKE() comparison. |
|
| 302 | - * @param mixed $y Argument to be used in ILIKE() comparison. |
|
| 303 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 304 | - * required when comparing text fields for oci compatibility |
|
| 305 | - * |
|
| 306 | - * @return string |
|
| 307 | - * @since 9.0.0 |
|
| 308 | - */ |
|
| 309 | - public function iLike($x, $y, $type = null): string { |
|
| 310 | - return $this->expressionBuilder->like($this->functionBuilder->lower($x), $this->functionBuilder->lower($y)); |
|
| 311 | - } |
|
| 298 | + /** |
|
| 299 | + * Creates a ILIKE() comparison expression with the given arguments. |
|
| 300 | + * |
|
| 301 | + * @param string $x Field in string format to be inspected by ILIKE() comparison. |
|
| 302 | + * @param mixed $y Argument to be used in ILIKE() comparison. |
|
| 303 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 304 | + * required when comparing text fields for oci compatibility |
|
| 305 | + * |
|
| 306 | + * @return string |
|
| 307 | + * @since 9.0.0 |
|
| 308 | + */ |
|
| 309 | + public function iLike($x, $y, $type = null): string { |
|
| 310 | + return $this->expressionBuilder->like($this->functionBuilder->lower($x), $this->functionBuilder->lower($y)); |
|
| 311 | + } |
|
| 312 | 312 | |
| 313 | - /** |
|
| 314 | - * Creates a NOT LIKE() comparison expression with the given arguments. |
|
| 315 | - * |
|
| 316 | - * @param ILiteral|IParameter|IQueryFunction|string $x Field in string format to be inspected by NOT LIKE() comparison. |
|
| 317 | - * @param mixed $y Argument to be used in NOT LIKE() comparison. |
|
| 318 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 319 | - * required when comparing text fields for oci compatibility |
|
| 320 | - * |
|
| 321 | - * @return string |
|
| 322 | - */ |
|
| 323 | - public function notLike($x, $y, $type = null): string { |
|
| 324 | - $x = $this->helper->quoteColumnName($x); |
|
| 325 | - $y = $this->helper->quoteColumnName($y); |
|
| 326 | - return $this->expressionBuilder->notLike($x, $y); |
|
| 327 | - } |
|
| 313 | + /** |
|
| 314 | + * Creates a NOT LIKE() comparison expression with the given arguments. |
|
| 315 | + * |
|
| 316 | + * @param ILiteral|IParameter|IQueryFunction|string $x Field in string format to be inspected by NOT LIKE() comparison. |
|
| 317 | + * @param mixed $y Argument to be used in NOT LIKE() comparison. |
|
| 318 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 319 | + * required when comparing text fields for oci compatibility |
|
| 320 | + * |
|
| 321 | + * @return string |
|
| 322 | + */ |
|
| 323 | + public function notLike($x, $y, $type = null): string { |
|
| 324 | + $x = $this->helper->quoteColumnName($x); |
|
| 325 | + $y = $this->helper->quoteColumnName($y); |
|
| 326 | + return $this->expressionBuilder->notLike($x, $y); |
|
| 327 | + } |
|
| 328 | 328 | |
| 329 | - /** |
|
| 330 | - * Creates a IN () comparison expression with the given arguments. |
|
| 331 | - * |
|
| 332 | - * @param ILiteral|IParameter|IQueryFunction|string $x The field in string format to be inspected by IN() comparison. |
|
| 333 | - * @param ILiteral|IParameter|IQueryFunction|string|array $y The placeholder or the array of values to be used by IN() comparison. |
|
| 334 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 335 | - * required when comparing text fields for oci compatibility |
|
| 336 | - * |
|
| 337 | - * @return string |
|
| 338 | - */ |
|
| 339 | - public function in($x, $y, $type = null): string { |
|
| 340 | - $x = $this->helper->quoteColumnName($x); |
|
| 341 | - $y = $this->helper->quoteColumnNames($y); |
|
| 342 | - return $this->expressionBuilder->in($x, $y); |
|
| 343 | - } |
|
| 329 | + /** |
|
| 330 | + * Creates a IN () comparison expression with the given arguments. |
|
| 331 | + * |
|
| 332 | + * @param ILiteral|IParameter|IQueryFunction|string $x The field in string format to be inspected by IN() comparison. |
|
| 333 | + * @param ILiteral|IParameter|IQueryFunction|string|array $y The placeholder or the array of values to be used by IN() comparison. |
|
| 334 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 335 | + * required when comparing text fields for oci compatibility |
|
| 336 | + * |
|
| 337 | + * @return string |
|
| 338 | + */ |
|
| 339 | + public function in($x, $y, $type = null): string { |
|
| 340 | + $x = $this->helper->quoteColumnName($x); |
|
| 341 | + $y = $this->helper->quoteColumnNames($y); |
|
| 342 | + return $this->expressionBuilder->in($x, $y); |
|
| 343 | + } |
|
| 344 | 344 | |
| 345 | - /** |
|
| 346 | - * Creates a NOT IN () comparison expression with the given arguments. |
|
| 347 | - * |
|
| 348 | - * @param ILiteral|IParameter|IQueryFunction|string $x The field in string format to be inspected by NOT IN() comparison. |
|
| 349 | - * @param ILiteral|IParameter|IQueryFunction|string|array $y The placeholder or the array of values to be used by NOT IN() comparison. |
|
| 350 | - * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 351 | - * required when comparing text fields for oci compatibility |
|
| 352 | - * |
|
| 353 | - * @return string |
|
| 354 | - */ |
|
| 355 | - public function notIn($x, $y, $type = null): string { |
|
| 356 | - $x = $this->helper->quoteColumnName($x); |
|
| 357 | - $y = $this->helper->quoteColumnNames($y); |
|
| 358 | - return $this->expressionBuilder->notIn($x, $y); |
|
| 359 | - } |
|
| 345 | + /** |
|
| 346 | + * Creates a NOT IN () comparison expression with the given arguments. |
|
| 347 | + * |
|
| 348 | + * @param ILiteral|IParameter|IQueryFunction|string $x The field in string format to be inspected by NOT IN() comparison. |
|
| 349 | + * @param ILiteral|IParameter|IQueryFunction|string|array $y The placeholder or the array of values to be used by NOT IN() comparison. |
|
| 350 | + * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants |
|
| 351 | + * required when comparing text fields for oci compatibility |
|
| 352 | + * |
|
| 353 | + * @return string |
|
| 354 | + */ |
|
| 355 | + public function notIn($x, $y, $type = null): string { |
|
| 356 | + $x = $this->helper->quoteColumnName($x); |
|
| 357 | + $y = $this->helper->quoteColumnNames($y); |
|
| 358 | + return $this->expressionBuilder->notIn($x, $y); |
|
| 359 | + } |
|
| 360 | 360 | |
| 361 | - /** |
|
| 362 | - * Creates a $x = '' statement, because Oracle needs a different check |
|
| 363 | - * |
|
| 364 | - * @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be inspected by the comparison. |
|
| 365 | - * @return string |
|
| 366 | - * @since 13.0.0 |
|
| 367 | - */ |
|
| 368 | - public function emptyString($x): string { |
|
| 369 | - return $this->eq($x, $this->literal('', IQueryBuilder::PARAM_STR)); |
|
| 370 | - } |
|
| 361 | + /** |
|
| 362 | + * Creates a $x = '' statement, because Oracle needs a different check |
|
| 363 | + * |
|
| 364 | + * @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be inspected by the comparison. |
|
| 365 | + * @return string |
|
| 366 | + * @since 13.0.0 |
|
| 367 | + */ |
|
| 368 | + public function emptyString($x): string { |
|
| 369 | + return $this->eq($x, $this->literal('', IQueryBuilder::PARAM_STR)); |
|
| 370 | + } |
|
| 371 | 371 | |
| 372 | - /** |
|
| 373 | - * Creates a `$x <> ''` statement, because Oracle needs a different check |
|
| 374 | - * |
|
| 375 | - * @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be inspected by the comparison. |
|
| 376 | - * @return string |
|
| 377 | - * @since 13.0.0 |
|
| 378 | - */ |
|
| 379 | - public function nonEmptyString($x): string { |
|
| 380 | - return $this->neq($x, $this->literal('', IQueryBuilder::PARAM_STR)); |
|
| 381 | - } |
|
| 372 | + /** |
|
| 373 | + * Creates a `$x <> ''` statement, because Oracle needs a different check |
|
| 374 | + * |
|
| 375 | + * @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be inspected by the comparison. |
|
| 376 | + * @return string |
|
| 377 | + * @since 13.0.0 |
|
| 378 | + */ |
|
| 379 | + public function nonEmptyString($x): string { |
|
| 380 | + return $this->neq($x, $this->literal('', IQueryBuilder::PARAM_STR)); |
|
| 381 | + } |
|
| 382 | 382 | |
| 383 | - /** |
|
| 384 | - * Binary AND Operator copies a bit to the result if it exists in both operands. |
|
| 385 | - * |
|
| 386 | - * @param string|ILiteral $x The field or value to check |
|
| 387 | - * @param int $y Bitmap that must be set |
|
| 388 | - * @return IQueryFunction |
|
| 389 | - * @since 12.0.0 |
|
| 390 | - */ |
|
| 391 | - public function bitwiseAnd($x, int $y): IQueryFunction { |
|
| 392 | - return new QueryFunction($this->connection->getDatabasePlatform()->getBitAndComparisonExpression( |
|
| 393 | - $this->helper->quoteColumnName($x), |
|
| 394 | - $y |
|
| 395 | - )); |
|
| 396 | - } |
|
| 383 | + /** |
|
| 384 | + * Binary AND Operator copies a bit to the result if it exists in both operands. |
|
| 385 | + * |
|
| 386 | + * @param string|ILiteral $x The field or value to check |
|
| 387 | + * @param int $y Bitmap that must be set |
|
| 388 | + * @return IQueryFunction |
|
| 389 | + * @since 12.0.0 |
|
| 390 | + */ |
|
| 391 | + public function bitwiseAnd($x, int $y): IQueryFunction { |
|
| 392 | + return new QueryFunction($this->connection->getDatabasePlatform()->getBitAndComparisonExpression( |
|
| 393 | + $this->helper->quoteColumnName($x), |
|
| 394 | + $y |
|
| 395 | + )); |
|
| 396 | + } |
|
| 397 | 397 | |
| 398 | - /** |
|
| 399 | - * Binary OR Operator copies a bit if it exists in either operand. |
|
| 400 | - * |
|
| 401 | - * @param string|ILiteral $x The field or value to check |
|
| 402 | - * @param int $y Bitmap that must be set |
|
| 403 | - * @return IQueryFunction |
|
| 404 | - * @since 12.0.0 |
|
| 405 | - */ |
|
| 406 | - public function bitwiseOr($x, int $y): IQueryFunction { |
|
| 407 | - return new QueryFunction($this->connection->getDatabasePlatform()->getBitOrComparisonExpression( |
|
| 408 | - $this->helper->quoteColumnName($x), |
|
| 409 | - $y |
|
| 410 | - )); |
|
| 411 | - } |
|
| 398 | + /** |
|
| 399 | + * Binary OR Operator copies a bit if it exists in either operand. |
|
| 400 | + * |
|
| 401 | + * @param string|ILiteral $x The field or value to check |
|
| 402 | + * @param int $y Bitmap that must be set |
|
| 403 | + * @return IQueryFunction |
|
| 404 | + * @since 12.0.0 |
|
| 405 | + */ |
|
| 406 | + public function bitwiseOr($x, int $y): IQueryFunction { |
|
| 407 | + return new QueryFunction($this->connection->getDatabasePlatform()->getBitOrComparisonExpression( |
|
| 408 | + $this->helper->quoteColumnName($x), |
|
| 409 | + $y |
|
| 410 | + )); |
|
| 411 | + } |
|
| 412 | 412 | |
| 413 | - /** |
|
| 414 | - * Quotes a given input parameter. |
|
| 415 | - * |
|
| 416 | - * @param mixed $input The parameter to be quoted. |
|
| 417 | - * @param mixed|null $type One of the IQueryBuilder::PARAM_* constants |
|
| 418 | - * |
|
| 419 | - * @return ILiteral |
|
| 420 | - */ |
|
| 421 | - public function literal($input, $type = null): ILiteral { |
|
| 422 | - return new Literal($this->expressionBuilder->literal($input, $type)); |
|
| 423 | - } |
|
| 413 | + /** |
|
| 414 | + * Quotes a given input parameter. |
|
| 415 | + * |
|
| 416 | + * @param mixed $input The parameter to be quoted. |
|
| 417 | + * @param mixed|null $type One of the IQueryBuilder::PARAM_* constants |
|
| 418 | + * |
|
| 419 | + * @return ILiteral |
|
| 420 | + */ |
|
| 421 | + public function literal($input, $type = null): ILiteral { |
|
| 422 | + return new Literal($this->expressionBuilder->literal($input, $type)); |
|
| 423 | + } |
|
| 424 | 424 | |
| 425 | - /** |
|
| 426 | - * Returns a IQueryFunction that casts the column to the given type |
|
| 427 | - * |
|
| 428 | - * @param string $column |
|
| 429 | - * @param mixed $type One of IQueryBuilder::PARAM_* |
|
| 430 | - * @return IQueryFunction |
|
| 431 | - */ |
|
| 432 | - public function castColumn(string $column, $type): IQueryFunction { |
|
| 433 | - return new QueryFunction( |
|
| 434 | - $this->helper->quoteColumnName($column) |
|
| 435 | - ); |
|
| 436 | - } |
|
| 425 | + /** |
|
| 426 | + * Returns a IQueryFunction that casts the column to the given type |
|
| 427 | + * |
|
| 428 | + * @param string $column |
|
| 429 | + * @param mixed $type One of IQueryBuilder::PARAM_* |
|
| 430 | + * @return IQueryFunction |
|
| 431 | + */ |
|
| 432 | + public function castColumn(string $column, $type): IQueryFunction { |
|
| 433 | + return new QueryFunction( |
|
| 434 | + $this->helper->quoteColumnName($column) |
|
| 435 | + ); |
|
| 436 | + } |
|
| 437 | 437 | } |
@@ -24,14 +24,14 @@ |
||
| 24 | 24 | namespace OC\DB\QueryBuilder\ExpressionBuilder; |
| 25 | 25 | |
| 26 | 26 | class SqliteExpressionBuilder extends ExpressionBuilder { |
| 27 | - /** |
|
| 28 | - * @inheritdoc |
|
| 29 | - */ |
|
| 30 | - public function like($x, $y, $type = null): string { |
|
| 31 | - return parent::like($x, $y, $type) . " ESCAPE '\\'"; |
|
| 32 | - } |
|
| 27 | + /** |
|
| 28 | + * @inheritdoc |
|
| 29 | + */ |
|
| 30 | + public function like($x, $y, $type = null): string { |
|
| 31 | + return parent::like($x, $y, $type) . " ESCAPE '\\'"; |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - public function iLike($x, $y, $type = null): string { |
|
| 35 | - return $this->like($this->functionBuilder->lower($x), $this->functionBuilder->lower($y), $type); |
|
| 36 | - } |
|
| 34 | + public function iLike($x, $y, $type = null): string { |
|
| 35 | + return $this->like($this->functionBuilder->lower($x), $this->functionBuilder->lower($y), $type); |
|
| 36 | + } |
|
| 37 | 37 | } |
@@ -28,7 +28,7 @@ |
||
| 28 | 28 | * @inheritdoc |
| 29 | 29 | */ |
| 30 | 30 | public function like($x, $y, $type = null): string { |
| 31 | - return parent::like($x, $y, $type) . " ESCAPE '\\'"; |
|
| 31 | + return parent::like($x, $y, $type)." ESCAPE '\\'"; |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | public function iLike($x, $y, $type = null): string { |
@@ -29,26 +29,26 @@ |
||
| 29 | 29 | |
| 30 | 30 | class MySqlExpressionBuilder extends ExpressionBuilder { |
| 31 | 31 | |
| 32 | - /** @var string */ |
|
| 33 | - protected $charset; |
|
| 32 | + /** @var string */ |
|
| 33 | + protected $charset; |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * @param ConnectionAdapter $connection |
|
| 37 | - * @param IQueryBuilder $queryBuilder |
|
| 38 | - */ |
|
| 39 | - public function __construct(ConnectionAdapter $connection, IQueryBuilder $queryBuilder) { |
|
| 40 | - parent::__construct($connection, $queryBuilder); |
|
| 35 | + /** |
|
| 36 | + * @param ConnectionAdapter $connection |
|
| 37 | + * @param IQueryBuilder $queryBuilder |
|
| 38 | + */ |
|
| 39 | + public function __construct(ConnectionAdapter $connection, IQueryBuilder $queryBuilder) { |
|
| 40 | + parent::__construct($connection, $queryBuilder); |
|
| 41 | 41 | |
| 42 | - $params = $connection->getInner()->getParams(); |
|
| 43 | - $this->charset = isset($params['charset']) ? $params['charset'] : 'utf8'; |
|
| 44 | - } |
|
| 42 | + $params = $connection->getInner()->getParams(); |
|
| 43 | + $this->charset = isset($params['charset']) ? $params['charset'] : 'utf8'; |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * @inheritdoc |
|
| 48 | - */ |
|
| 49 | - public function iLike($x, $y, $type = null): string { |
|
| 50 | - $x = $this->helper->quoteColumnName($x); |
|
| 51 | - $y = $this->helper->quoteColumnName($y); |
|
| 52 | - return $this->expressionBuilder->comparison($x, ' COLLATE ' . $this->charset . '_general_ci LIKE', $y); |
|
| 53 | - } |
|
| 46 | + /** |
|
| 47 | + * @inheritdoc |
|
| 48 | + */ |
|
| 49 | + public function iLike($x, $y, $type = null): string { |
|
| 50 | + $x = $this->helper->quoteColumnName($x); |
|
| 51 | + $y = $this->helper->quoteColumnName($y); |
|
| 52 | + return $this->expressionBuilder->comparison($x, ' COLLATE ' . $this->charset . '_general_ci LIKE', $y); |
|
| 53 | + } |
|
| 54 | 54 | } |
@@ -49,6 +49,6 @@ |
||
| 49 | 49 | public function iLike($x, $y, $type = null): string { |
| 50 | 50 | $x = $this->helper->quoteColumnName($x); |
| 51 | 51 | $y = $this->helper->quoteColumnName($y); |
| 52 | - return $this->expressionBuilder->comparison($x, ' COLLATE ' . $this->charset . '_general_ci LIKE', $y); |
|
| 52 | + return $this->expressionBuilder->comparison($x, ' COLLATE '.$this->charset.'_general_ci LIKE', $y); |
|
| 53 | 53 | } |
| 54 | 54 | } |
@@ -30,30 +30,30 @@ |
||
| 30 | 30 | |
| 31 | 31 | class PgSqlExpressionBuilder extends ExpressionBuilder { |
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * Returns a IQueryFunction that casts the column to the given type |
|
| 35 | - * |
|
| 36 | - * @param string $column |
|
| 37 | - * @param mixed $type One of IQueryBuilder::PARAM_* |
|
| 38 | - * @return IQueryFunction |
|
| 39 | - */ |
|
| 40 | - public function castColumn($column, $type): IQueryFunction { |
|
| 41 | - switch ($type) { |
|
| 42 | - case IQueryBuilder::PARAM_INT: |
|
| 43 | - return new QueryFunction('CAST(' . $this->helper->quoteColumnName($column) . ' AS INT)'); |
|
| 44 | - case IQueryBuilder::PARAM_STR: |
|
| 45 | - return new QueryFunction('CAST(' . $this->helper->quoteColumnName($column) . ' AS TEXT)'); |
|
| 46 | - default: |
|
| 47 | - return parent::castColumn($column, $type); |
|
| 48 | - } |
|
| 49 | - } |
|
| 33 | + /** |
|
| 34 | + * Returns a IQueryFunction that casts the column to the given type |
|
| 35 | + * |
|
| 36 | + * @param string $column |
|
| 37 | + * @param mixed $type One of IQueryBuilder::PARAM_* |
|
| 38 | + * @return IQueryFunction |
|
| 39 | + */ |
|
| 40 | + public function castColumn($column, $type): IQueryFunction { |
|
| 41 | + switch ($type) { |
|
| 42 | + case IQueryBuilder::PARAM_INT: |
|
| 43 | + return new QueryFunction('CAST(' . $this->helper->quoteColumnName($column) . ' AS INT)'); |
|
| 44 | + case IQueryBuilder::PARAM_STR: |
|
| 45 | + return new QueryFunction('CAST(' . $this->helper->quoteColumnName($column) . ' AS TEXT)'); |
|
| 46 | + default: |
|
| 47 | + return parent::castColumn($column, $type); |
|
| 48 | + } |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * @inheritdoc |
|
| 53 | - */ |
|
| 54 | - public function iLike($x, $y, $type = null): string { |
|
| 55 | - $x = $this->helper->quoteColumnName($x); |
|
| 56 | - $y = $this->helper->quoteColumnName($y); |
|
| 57 | - return $this->expressionBuilder->comparison($x, 'ILIKE', $y); |
|
| 58 | - } |
|
| 51 | + /** |
|
| 52 | + * @inheritdoc |
|
| 53 | + */ |
|
| 54 | + public function iLike($x, $y, $type = null): string { |
|
| 55 | + $x = $this->helper->quoteColumnName($x); |
|
| 56 | + $y = $this->helper->quoteColumnName($y); |
|
| 57 | + return $this->expressionBuilder->comparison($x, 'ILIKE', $y); |
|
| 58 | + } |
|
| 59 | 59 | } |
@@ -40,9 +40,9 @@ |
||
| 40 | 40 | public function castColumn($column, $type): IQueryFunction { |
| 41 | 41 | switch ($type) { |
| 42 | 42 | case IQueryBuilder::PARAM_INT: |
| 43 | - return new QueryFunction('CAST(' . $this->helper->quoteColumnName($column) . ' AS INT)'); |
|
| 43 | + return new QueryFunction('CAST('.$this->helper->quoteColumnName($column).' AS INT)'); |
|
| 44 | 44 | case IQueryBuilder::PARAM_STR: |
| 45 | - return new QueryFunction('CAST(' . $this->helper->quoteColumnName($column) . ' AS TEXT)'); |
|
| 45 | + return new QueryFunction('CAST('.$this->helper->quoteColumnName($column).' AS TEXT)'); |
|
| 46 | 46 | default: |
| 47 | 47 | return parent::castColumn($column, $type); |
| 48 | 48 | } |