PHP Method Return

Hi - I have not used PHP Methods before and have a blank application that will have numerous sql queries and a fair amount of html on it.
I would to put some of the queries as php methods (to keep the page less cluttered and manageable) and call the results back into the “on execute” event section.

My question is how to i return the query results back from the method?

Thanks in advance.
Andy

Here is an example of one of the queries, with variables picking up the results.
sc_lookup(ds,“SELECT ROUND(AVG (benchmarks.accs_online),1),
ROUND(AVG(benchmarks.accs_store),1),
ROUND(AVG(benchmarks.orders_online),1),
ROUND(AVG(benchmarks.orders_store),1),
ROUND(AVG(benchmarks.udrives_online),1),
ROUND(AVG(benchmarks.udrives_store),1),
ROUND(AVG(benchmarks.conv_accs),1),
ROUND(AVG(benchmarks.conv_udrives),1),
ROUND(AVG(benchmarks.pen_fin),1),
ROUND(AVG(benchmarks.pen_px),1),
ROUND(AVG(benchmarks.pen_px_conq),1)
FROM benchmarks”);
$bmOA = {ds[0][0]};
$bmSA = {ds[0][1]};
$bmOO = {ds[0][2]};
$bmSO = {ds[0][3]};
$bmOYD = {ds[0][4]};
$bmSYD = {ds[0][5]};
$bmACon = {ds[0][6]};
$bmYDCon = {ds[0][7]};
$bmFinP = {ds[0][8]};
$bmPX = {ds[0][9]};
$bmPXConq = {ds[0][10]};

You can create a method and return a Array.

Thanks for your reply :slight_smile:
Do we know of a tutorial of code eample of how this might look within scriptcase?

Try This:

Programming -> PHP Methods -> New Method
Enter you Mehod Name. ex: get_data Click in Button CREATE.

Put your code here for get your data into the function. ex:

$out[‘a’] = “abc”;
$out[‘b’] = “def”;
$out[‘c’] = “ghi”;

return $out;

Now, Click in button Save. your method is created.

It Can be called from ONExecute event:

$data = get_data();
echo $data[‘a’];
echo $data[‘b’];
echo $data[‘c’];

Thanks for this, I will give it a try once I get back to the project shortly.