Commit ceb35066 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Refs #11998 - Add explanation to qfq function example code.

parent da4212db
Pipeline #5052 passed with stages
in 3 minutes and 40 seconds
...@@ -1948,14 +1948,15 @@ QFQ Function ...@@ -1948,14 +1948,15 @@ QFQ Function
QFQ SQL reports can be reused, similar to a function in a regular programming language, including call parameter and return QFQ SQL reports can be reused, similar to a function in a regular programming language, including call parameter and return
values. values.
* Per tt-content record the field 'subheader' (in Typo3 backend) has to be used to define the function name. The function * Per tt-content record the field 'subheader' (in Typo3 backend) defines the function name. The function
can also referenced by using the tt-content number (`uid`) - but this is less readable. can also referenced by using the tt-content number (`uid`) - but this is less readable.
* The calling report calls the function by defining ``<level>.function = <function name>(var1, var2, ...) => return1, return2, ...`` * The calling report calls the function by defining ``<level>.function = <function name>(var1, var2, ...) => return1, return2, ...``
* STORE_RECORD will be saved before calling the function and will be restored when the function has been finished. * STORE_RECORD will be saved before calling the function and will be restored when the function has been finished.
* Exception: the defined function call parameter and function return values will be filled and processed via STORE_RECORD. * The function has only access to STORE_RECORD variables which has been explicitly defined in the braces (var1, var2, ...).
* Inside the QFQ function, all STORES are available. * The function return values will be copied to STORE_RECORD after the function finished.
* Inside the QFQ function, all other STORES are fully available.
* If ``<level>.function`` and ``<level>.sql`` are both given, ``<level>.function`` is processed first. * If ``<level>.function`` and ``<level>.sql`` are both given, ``<level>.function`` is processed first.
* If ``<level>.function`` is given, but ``<level>.sql`` not, the values of ``shead, stail, althead`` are processed. * If ``<level>.function`` is given, but ``<level>.sql`` not, the values of ``shead, stail, althead`` are even processed.
* If a function outputs something, this is *not* shown. * If a function outputs something, this is *not* shown.
* The output of a QFQ function is accessible via ``{{_output:R}}``. * The output of a QFQ function is accessible via ``{{_output:R}}``.
* It is possible to call functions inside of a function. * It is possible to call functions inside of a function.
...@@ -1969,7 +1970,7 @@ Example tt-content record for the function:: ...@@ -1969,7 +1970,7 @@ Example tt-content record for the function::
# #
render = api render = api
10 { 100 {
  sql = SELECT p.firstName AS _firstName   sql = SELECT p.firstName AS _firstName
               , NOW() AS now, CONCAT('p:{{pageAlias:T}}&form=person&r=', p.id ) AS '_pagee|_hide|myLink'                            , NOW() AS now, CONCAT('p:{{pageAlias:T}}&form=person&r=', p.id ) AS '_pagee|_hide|myLink'            
          FROM Person AS p           FROM Person AS p
...@@ -2003,6 +2004,15 @@ Example tt-content record for the calling report:: ...@@ -2003,6 +2004,15 @@ Example tt-content record for the calling report::
  }   }
}                                                                     }                                                                    
Explanation:
* Level 10 iterates over all `person`.
* Level 10.20 calls QFQ function `getFirstName()` by delivering the `pId` via STORE_RECORD. The function expects the return
value `firstName` and `myLink`.
* The function selects in level 100 the person given by ``{{pId:R}}``. The `firstName` is not printed but a hidden column.
Column ``now`` is printed. Column 'myLink' is a rendered link, but not printed.
* Level 10.30 prints the return values ``firstName`` and ``myLink`` (as rendered link and as source definition). The last
column is the output of the function - the value of ``NOW()``
.. _download: .. _download:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment