calculated fields between table

Your current DaDaBIK version​

You are using DaDaBIK version 11.9-Elba enterprise, installed on 04-26-2023 (installation code: 1881264496c38a82eb), the latest version of DaDaBIK is 11.9-Elba released on 03-23-2023

You are running the latest release of DaDaBIK

In case you want to upgrade to a more powerful edition (from Pro to Enterprise/Platinum, from Enterprise to Platinum) please contact us.

System info​

PHP Version: 8.1.0

mysql version: 5.7.24

Web server: Apache/2.4.33 (Win64) OpenSSL/1.0.2u mod_fcgid/2.3.9 PHP/8.1.0

Client: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36

URL installation: http://localhost/my_dadabik_directory/

Hi
I have 2 table,
in table1 I have the field "GIORNI" that contain an int number (numbers of day)
in table2 I have the field "DATA" that as the name suggest is a date in italian format dd-mm-yyyy
in table2 I want to fill the field "SCADENZA" as DATA+GIORNI
I suppose the correct way to do it is with a function to insert in the calculated_fields_functions.php and then set the function in the form configurator.

I made several test without good result.
Could you help?

Regards
Giuseppe
 
just to add some info... I am able to do the job if all the data are in same table with the following code:

function dadabik_scadenza ($params){
$date = $params['data'];
$interval = $params['giorni'];
return date('d-m-Y', strtotime($date. ' + '. $interval . ' days'));

how can I modify it to make it work with different tables?
 

deep64blue

DaDaBIK Guru
You can run an sql query within the function to get the data from the other table, here's an example from my application.

PHP:
$sql = "UPDATE `ret_returns` a INNER JOIN `ret_bvenue` b on b.bvenID=a.bvenue SET a.`location`=b.bvenue WHERE a.`bvenue` IS NOT NULL AND `returnID`=:id";
   
    $res_prepare = prepare_db($conn, $sql);

    $res_bind = bind_param_db($res_prepare, ':id', $id);
   
    $res = execute_prepared_db($res_prepare,0);
 
Top