This topic is locked
[SOLVED]

 Access grid data avoiding a new query

6/7/2016 11:41:10 AM
PHPRunner General questions
A
Alessio author

Hello everybody
In PHPRunner 8.1 I need to add a custom chart (google chart) in a list page.

To build this chart I need to use the same data are shown in the grid of this page.

The question is:

Is it possible retrieve the query data from a code snippet, avoiding a new query?
As workaround in this moment I do this

  • in events-> after record processed I save each row in a session array
  • later inside the snippet I use the data to buld the chart and I unset the session var
    I also test this other way:
  • in events-> fetch records I copy $rs object in session
  • inside the snippet I use the result object to build the chart.

    BUT

    If I do so, data in the grid are not printed anymore.

    (to be honest even just a comment in this event page blocks the data grid printing).

    So I went back to first workaround.
    Many thanks

Sergey Kornilov admin 6/7/2016

You can use event like BeforeRecordProcessed for this purpose:

http://xlinesoft.com/phprunner/docs/before_record_processed.htm
Save each new data row ($data) in session variable and then use it in your code snippet.

$_SESSION["mydata"][]=$data;


Do not forget to reset this session variable on page load i.e. in BeforeProcess event.

A
Alessio author 6/7/2016

Perfect, so you confirm session is the right choice!
Many thanks