Insert a local variable in database

Hi!

I have this script in my event of grid.

$current_date = date(‘Y-m-d’);
{amount_days} = sc_date_dif({scadri}, ‘aaaa-mm-dd’, $current_date, ‘aaaa-mm-dd’);

if({amount_days} < 0)
{
sc_field_style({scadri}, “#ea3a43”);
sc_field_style({iscir}, “#ea3a43”);
sc_field_style({poz}, “#ea3a43”);
//if amount is bigger then 0, means that current date is bigger then {field_due_date}
//send an email to the user, this bill is overdue.
}
elseif({amount_days} < 60)…

I want to write “amount_days” variable in database for further aplication.

can you help me?

Thank you.

One issue you might come across is that on every time you show the grid, the database will be updated. But besides that, the solution is pretty easy. In your onrecord event you need to apply a bit of php. A code snippet can be found on your right ‘insert data into dataset’. Modify the sql to the statement you require. I.e. 'insert into mytable (amountdays,…) values ({amount_days}, …
Sometimes the parser goes wrong and you could need to rewrite to something like:

$sql=‘insert into mytable (amountdays, …) values (’.{amount_days}.’)’;

if amount_days needs to be stored as a string:

$sql=“insert into mytable (amountdays, …) values (’”.{amount_days}."’)’;

hope this helps.

Thank you!