Insert an agenda event from a simple php script

Hello there! I am trying to insert an agenda event directly in mySql from a PHP script (not a really good idea, I know, but I have to).
This is a simplified version of my attempt:

[code]

<?php $db = mysqli_connect('localhost','myuser','mypassword','dolibarr') or die('Error connecting to MySQL server.'); $now = date("Y-m-d H:i:s"); $fk_user = '1'; $fk_user_author = $fk_user; $fk_user_action = $fk_user; $datep = '2020-01-02 13:00:00'; $label = 'test label'; $note = 'test note'; $query = "INSERT INTO llx_actioncomm (datep, fk_action, code, datec, tms, fk_user_author, fk_user_mod, fk_user_action, transparency, priority, percent, label, note) VALUES ('$datep', 50, 'AC_OTH', '$now', '$now', $fk_user, $fk_user, $fk_user, 1, 0, -1, '$label', '$note')"; mysqli_query($db,$query) or die(mysqli_error($db)); mysqli_close($db);[/code] It works, sort of. At times it seems to insert the event, but it will not show on month view before I load day view (weird). But I don't know how to assign several users to the same event, I cannot find the appropriate field in llx_actioncomm. What can I do? [code] DOLIBARR ENVIRONMENT - Version: 8.0.1 - Operating System: Ubuntu Linux 18.04 Server LTS - Web Server: Apache/2.4.29 (Ubuntu) - PHP: 7.2.7-0ubuntu0.18.04.2 - Database: MySQL or MariaDB 5.7.23-0ubuntu0.18.04.1 - URL(s): http://192.168.1.9/dolibarr/htdocs/comm/action/index.php[/code]

Hi,

Why do you not use the API ?
https://wiki.dolibarr.org/index.php/Module_Web_Services_REST_(developer)

1 Like

Tried the rest API for events insertion, it works well. It can be a solution. Thanks.
Still, out of curiosity, where users assigned to an event are specified in the database? I’ve searched this information for days…

Is there any working example on how to create an agenda event via the rest API?
Tks