Read the content of a Grid in a php button

I would like to read all the lines of a Grid in a php code (button).

Is there a global var available ? an array ? in order to do an foreach loop on all the lines ?

I use to play with the run button, but now I need to call my code for all the lines (More than 100 000 lines).

Please help me if you know, or give me a piece of code.

Thank you in advance. :slight_smile:

Laurent.

You can work on your grid with the Run button. The Run button has 2 events: OnRecord: Executed on each selected record.
[SIZE=12px]Image2: PHP Code Interface.[/SIZE] OnFinish: Executed after process all selected records.


[SIZE=12px]Image3:PHP Code Interface[/SIZE]
You can get more information in the Web Help that Scriptcase has and also there is a sample with tutorial in the scriptcase website.

Hope this helps.

Thank you, but as i said before, i can’t use the OnRecord, because OnRecord only works with checked line on a single screen.

As i have lots off lines, i need to use the OnFinish but i don’t know if there is a global $var like an array I could use the parse.

I saw the tutorial but it’s not usable in my case (i need to parse all line of the grid filtered with numbers affinity parameters).

Have you any other ideas ?

If you need the lines of the current grid then the only way (afaik) is to use onrecord and store the record in a (global) array.

I do not know exactly what you are trying to accomplish but if I would need to work on on all the lines of a grid. like a batch update of a field, I have used stored procedures. I add a PHP button and I call the stored procedures from inside that button.

// PASTE HERE YOUR BASE SQL FOR THE GRID

$grid_qry = 'SELECT
    id,
FROM
    yourtable';

// WE ADD IF THERE IS SOME FILTER APPLIED
if ($sc_where_current) {
 $grid_qry .= ' ' . $sc_where_current;
}

// THROW THE QUERY AND USE YOUR DATA
sc_lookup(arrmygridcontent, $grid_qry);
if (isset($arrmygridcontent[0][0])) {
    // iterate over your grid content.
}