Need help using a hook to generate a CSV

mmaresca

Member
I am trying to generate a csv file every time a table is updated. Does anyone have
any relevant information or success with such a task?



You are using DaDaBIK version 10.3-Manarola enterprise, installed on 10-31-2020

PHP Version: 7.4.3

mysql version: 8.0.22-0ubuntu0.20.04.2

Web server: Apache/2.4.41 (Ubuntu) OpenSSL/1.1.1f

Client: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36
 

eugenio

Administrator
Staff member
Hello,
are you trying to generate a CSV file and store it in the file system I guess?
You should use an after update hook on your target table and write the generation code there. There isn't a specific DaDaBIK API you can call to generate the CSV so you should write your own code if you are familiar with PHP.

However, if in your code you call (for example through fopen() ) this URL:

index.php?tablename=YOURTABLE&function=search&export_to_csv=1

you should get as a response the CSV file; I haven't tested it but the active filters and sort criteria should be kept.

Best,
 
Top