File tree 1 file changed +27
-0
lines changed
1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -232,6 +232,33 @@ vendors SQL parser to show us further errors in the parsing
232
232
process, for example if the Unit would not be one of the supported
233
233
values by MySql.
234
234
235
+ Typed functions
236
+ ----------
237
+ By default, result of custom functions is fetched as-is from the database driver.
238
+ If you want to be sure the type is always the same, your custom function can
239
+ implement ``Doctrine\ORM\Query\AST\TypedExpression ``. Then, the result is wired
240
+ through ``convertToPhpValue `` method of the ``Type `` returned from ``getReturnType ``.
241
+
242
+ .. code-block :: php
243
+
244
+ <?php
245
+
246
+ use Doctrine\DBAL\Types\Type;
247
+ use Doctrine\DBAL\Types\Types;
248
+ use Doctrine\ORM\Query\AST\Functions\FunctionNode;
249
+ use Doctrine\ORM\Query\AST\TypedExpression;
250
+
251
+ class DateDiff extends FunctionNode implements TypedExpression
252
+ {
253
+ // ...
254
+
255
+ public function getReturnType(): Type
256
+ {
257
+ return Type::getType(Types::INTEGER);
258
+ }
259
+ }
260
+
261
+
235
262
Conclusion
236
263
----------
237
264
You can’t perform that action at this time.
0 commit comments