Update DB

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
jgregor
Posts: 12
Joined: 2020-01-13 04:44

Update DB

Post by jgregor » 2020-11-05 08:01

Hello, I am trying to finish a small application: I would like to improve a form where there are several decimal fields, I would like to calculate a field with the values of the other fields. I tried to insert this into events before update $ data ['Celkom'] = $data ['Hmotbody'] + $data ['Srstbody']; with success. In addition I would like to update the field another table with the value of field : Celkom . Could someone help me for the sintaxe. Or is this not the right place to achieve the desired result.Thank you

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1234
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: Update DB

Post by onoehring » 2020-11-05 15:05

Hi,

can't you do it like (code not tested) the code below?

Code to be placed in the after update function in /hooks/tabelename.php

Code: Select all

  $sql = "UPDATE yourtablename SET yourfieldname = " . $data['Celkom'] . " WHERE yourPrimaryKeyFieldinTable = " . $selected_ID . ";";
  $yourresult = sqlValue($sql);
Olaf

jgregor
Posts: 12
Joined: 2020-01-13 04:44

Re: Update DB

Post by jgregor » 2020-11-06 21:05

Hello onoehring and thank you very much for your help, I didn't manage to get your code to work but you helped me with the syntax. I finally found a less elegant form than yours which works for the moment. I also reconfigured my database so that the IDs match. You know, I am not a programmer I do a few small programs from time to time for our breeders association and in the meantime I forget the exact syntax a little. Thank you again.

function olkralikov_after_update ($ data, $ memberInfo, & $ args) {
$ id = makeSafe ($ data [id]);
$ sqlx = sqlValue ("Select Celkom from Olkralikov WHERE Olkralikov.id = $ id");
sql ("UPDATE Zviera SET Ocenenie = '$ sqlx' WHERE Zviera.id = $ id");
return TRUE;

Post Reply