add ddFinalQuery() function#45705
add ddFinalQuery() function#45705farshidrezaei wants to merge 3 commits intolaravel:9.xfrom farshidrezaei:patch-1
Conversation
This function replace bind bindings in to query and die and dump final query.
when you debugging complicated queries, you need to get final query without complexity.
if you do like bellow :
```php
User::where('name','farshid')->dd();
```
For example you will get bellow result:
```
"SELECT * FROM users WHERE name=?;",
[
0 => "farshid"
]
```
But if you calling
```php
User::where('name','farshid')->ddFinalQuery();
```
You will get bellow result:
```
"SELECT * FROM users WHERE name='farshid';"
```
|
We all want such a function, however it is not as easy as it seems 😅 #39551 mentions the problems for postgresql in a comment (#38027 (comment)) |
|
Thanks for your pull request to Laravel! Unfortunately, I'm going to delay merging this code for now. To preserve our ability to adequately maintain the framework, we need to be very careful regarding the amount of code we include. If possible, please consider releasing your code as a package so that the community can still take advantage of your contributions! If you feel absolutely certain that this code corrects a bug in the framework, please "@" mention me in a follow-up comment with further explanation so that GitHub will send me a notification of your response. |
|
@farshidrezaei I decided to create a package for this :) Example code: |
|
@nathanjansen that's good. i will contribute. |
This function replace bind bindings in to query and die and dump final query. when you debugging complicated queries, you need to get final query without complexity.
if you do like bellow :
For example you will get bellow result:
But if you calling
You will get bellow result: