Hi Sematik,
I need your help with enable_live_update. It runs correctly if use render_table, but with a script like this:
<?php header ("Content-Type: text / html; charset = utf-8"); require("../codebase/connector/grid_connector.php"); $res= new PDO("mysql:dbname=my_mbo;host=localhost","root",""); $conn = new GridConnector($res,"PDO"); $conn->enable_live_update('actions_table'); $conn->event->attach("beforeinsert","myInsert"); $conn->enable_log("temp.log"); if ($conn->is_select_mode()){ $conn->render_sql("Select id, magazzino.codice, descrizione, categoria, um, ubicazione, nota, quantita, quantita - qta_prenotata - qta_fuori as qta_disponibile,qta_prenotata,qta_fuori, nota as nota2 from magazzino, saldi where magazzino.codice = saldi.codice and magazzino.codice <> ''","id","codice,descrizione,categoria,um,ubicazione,nota,quantita,qta_disponibile, qta_prenotata,qta_fuori, nota2"); } else { $conn->render_table("magazzino","id","codice,descrizione,categoria,um,ubicazione,nota"); } function myInsert($action){ if($action->get_value("codice")=="") $action->set_value("codice",null); } ?>the command set_AutoUpdate(2000);
give an error (from log):
====================================
Log started, 24/12/2023 07:09:37
Editing = Updating = 1
Editing = Updating = 1
SELECT magazzino, saldi.*, actions_table.id, actions_table.dataId, actions_table.type as action_table_type, actions_table.user FROM actions_table LEFT OUTER JOIN magazzino, saldi ON actions_table.DATAID = magazzino, saldi.id WHERE ( magazzino.codice = saldi.codice and magazzino.codice <> ‘’) AND ( actions_table.ID > ‘59’ AND actions_table.USER <> ‘1703441375927’)
!!!Uncaught Exception
Code: 42000
Message: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ’ saldi ON actions_table.DATAID = magazzino, saldi.id WHERE ( magazzino.codice…’ at line 1
It creates a wrong query but i dont know why.
Is the command enable_live_update usable only with render_table and not with render_sql ? or is not usable with “if ($conn->is_select_mode())” ? or there is something else wrong ?
Thank you very much