Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Using Before Edit PHP Code Example

Questions related to using nuBuilder Forte.
Post Reply
tonyd
Posts: 68
Joined: Sun Mar 04, 2018 6:38 pm

Using Before Edit PHP Code Example

Unread post by tonyd »

Does anyone have an example of code they have used in their "Before Edit" PHP section of a form? I am trying to wrap my head around how to use this feature in my situation, but I have brain lock and need a sharp kick in the imagination.

What I am trying to do is to programmatically set up a temp table to be used in a browse form. Also hoping for a hint on how to use a stored MySQL procedure as part of the solution.

TIA
TonyD
admin
Site Admin
Posts: 2815
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Using Before Edit PHP Code Example

Unread post by admin »

tonyd,

I hope this helps.
tt1.PNG
tt2.PNG
tt3.PNG

Code: Select all

nuRunQuery("CREATE TABLE #TABLE_ID# SELECT * FROM aaa");
nuRunQuery("UPDATE #TABLE_ID# SET field00 = 'hello'");

Steven
You do not have the required permissions to view the files attached to this post.
tonyd
Posts: 68
Joined: Sun Mar 04, 2018 6:38 pm

Re: Using Before Edit PHP Code Example

Unread post by tonyd »

Are you suggesting I use a hash cookie for the table name?
TonyD
admin
Site Admin
Posts: 2815
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Using Before Edit PHP Code Example

Unread post by admin »

tonyd,

Yes that's correct.

Steven
tonyd
Posts: 68
Joined: Sun Mar 04, 2018 6:38 pm

Re: Using Before Edit PHP Code Example

Unread post by tonyd »

Ok, cool. I got the browse form to load. Unfortunately, when I click on one of its rows I get the edit form but with all blank fields except for the subforms, which seem to have populated just fine. Any ideas?
TonyD
admin
Site Admin
Posts: 2815
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Using Before Edit PHP Code Example

Unread post by admin »

tonyd,

You'll need to make sure the Primary Key is the correct field in your temp table.

This is what takes you to the correct record.
tt4.PNG
Steven
You do not have the required permissions to view the files attached to this post.
tonyd
Posts: 68
Joined: Sun Mar 04, 2018 6:38 pm

Re: Using Before Edit PHP Code Example

Unread post by tonyd »

After some head scratching I finally got it to work after separating my BROWSEEDIT form into a unique BROWSE and EDIT form. Also had to add the primary key column to my select statement.

One question remains...Do I need to perform any housekeeping like dropping #TABLE_ID# before opening the EDIT form?

Thanks for all the help!
TonyD
admin
Site Admin
Posts: 2815
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Using Before Edit PHP Code Example

Unread post by admin »

TonyD,

The #TABLE_ID# will drop itself.

Steven
Post Reply