3

When trying to express SQL joins with API4 I feel the need to check the SQL that's being created, as there's some 'magic' that might or might not be happening.

It wasn't clear to me how to do this.

3 Answers 3

4

Alternatively ...

  1. fire up api4 explorer and prepare your query. Make sure to ✔ the debug option
  2. execute the query
  3. click the 'Debug' tab next to the 'Result' tab

enter image description here

1
  • ooh, I don't see that on 5.36, perhaps it came later. Commented Jun 25, 2021 at 16:25
2

You can do this from the API explorer if you use your browser's dev tools.

  1. fire up api4 explorer and prepare your query. Make sure to ✔ the debug option, and un-✔ the check permissions box.
  2. open your browser's dev tools console
  3. execute the query
  4. inspect the network response JSON: at the top level (the same level as values you'll see a debug entry, which includes the SQL.
1

You can do this via code by adding ->setDebug(TRUE) as a parametr to your call. Then, when you get the results (e.g. $results) examine $results['debug']['sql'][0].

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.