Creating Auto Fields in a Table

Got something cool to share with AppGini users? Feel free to post it here!
Post Reply
gatenet
Veteran Member
Posts: 45
Joined: 2016-07-26 09:34
Location: Greece
Contact:

Creating Auto Fields in a Table

Post by gatenet » 2021-06-17 09:40

Hello all, here is my situation.
I want to make a table with services that will have some fields (id, service name etc) then I want to make another table that will pull dynamic the records from the first table and turn them into fields. For example in the table services a user will put 2 records let's say Webhosting and Domain Names, so the second table will have these 2 records for fields (Webhosting and Domain Names) after some time the user will create a new record let's say Support, then I want the second table to have a third field called Support.
Is there any way to make this?

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Creating Auto Fields in a Table

Post by pbottcher » 2021-06-17 19:05

Hi,

not sure I got exactly what you mean, but if the second table is kind of a single record with all the records from the first table (for one field), then you could have one field to hold an index for the user and a second field that would hold all entries from the first table.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Creating Auto Fields in a Table

Post by jsetzer » 2021-06-18 05:16

So you'd like to turn records of one table into columns of a second table like so:

Table "Services"

Code: Select all

-id
-name
Data
1 ; Webhosting
2 ; Domain Names
3 ; Support

Table "TABLE2"

Code: Select all

-id
-webhosting
-domain_names
-support
That's not possible "on the fly" with standard AppGini, because AppGini requires a static model for generating database tables, serverside- and clientside code and user interface. When working with AppGini, AppGini itself does not know about any records inside any existing database on any remote or local server at all.

You may consider using a SQL command in _after_insert hook of "services" table for creating new columns in TABLE2.
You may consider renaming existing columns in TABLE2 in before_update/after_update hook of "services" table using SQL.
You may consider deleting existing columns in TABLE2 in before_delete hook of "services" table using SQL.

But creating/modifying/deleting columns this will not change any User Interface.

Adding dynamic forms for data entry and listing of data, data-validation and serverside storage after POST will be separate tasks.

That's quite a lot of work.
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

gatenet
Veteran Member
Posts: 45
Joined: 2016-07-26 09:34
Location: Greece
Contact:

Re: Creating Auto Fields in a Table

Post by gatenet » 2021-06-24 19:31

Thank you my friend I will look at it

Post Reply