Hello,
I'm fighting with a pretty easy task.
In the edit screen of an item, I want to add a button that does some SQL stuff. (duplaction of the current item + some modifications...) I already have working SQL code.
First I thought: easy. I just have to add an Object and configure it as "Run" button and select a previously added SQL. But it is not possible to select any SQL from a run button.
Then I tried to add a PHP Procedure and used the "nuRunQuery" function to execute every SQL line step by step. But also here I can't select the procedure from the "Run" reference selector.
I hope somebody can help.
BR
Welcome to the nuBuilder Forums!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums and content available only to registered users.
Execute SQL on button click
-
- Posts: 38
- Joined: Wed May 29, 2019 2:50 pm
Re: Execute SQL on button click
Seems that I found out why the new php procedure was not shown in the selector.
zzzzsys_php.sph_run must not be NULL but ""
and
zzzzsys_php.sph_system must not be NULL but ""
zzzzsys_php.sph_run must not be NULL but ""
and
zzzzsys_php.sph_system must not be NULL but ""
-
- Posts: 38
- Joined: Wed May 29, 2019 2:50 pm
Re: Execute SQL on button click
Now I have the next problem that I need to get the id of the current element and use it in the SQL.
First I thought of something like this:
but it seems that it is not working.
First I thought of something like this:
Code: Select all
nuRunQuery("CREATE TEMPORARY TABLE `_copy_table_temp` SELECT * FROM `dl_projects` WHERE `dl_projects_id` = '".nuLookupRecord()->dl_projects_id."';");
-
- Posts: 38
- Joined: Wed May 29, 2019 2:50 pm
Re: Execute SQL on button click
Maybe the "Filter" or the "Record ID" fields can be used somehow from the Run object?
-
- nuBuilder Team
- Posts: 508
- Joined: Fri Dec 28, 2018 1:41 pm
- Location: Krakow, Poland
- Has thanked: 10 times
- Been thanked: 18 times
Re: Execute SQL on button click
If you want to read the code from the Lookup object on the current form just use in the php:
and
Code: Select all
$x=('#ID_of_the_object#');
Code: Select all
.... WHERE par_number='$x';"; //for string
or
.... WHERE con_part=$x;"; //for int
If you like nuBuilder, please leave a review on SourceForge
-
- Posts: 38
- Joined: Wed May 29, 2019 2:50 pm
Re: Execute SQL on button click
Thank you very much.Janusz wrote:If you want to read the code from the Lookup object on the current form just use in the php:andCode: Select all
$x=('#ID_of_the_object#');
Code: Select all
.... WHERE par_number='$x';"; //for string or .... WHERE con_part=$x;"; //for int
It works.