Settings.

If you're a new user of AppGini, feel free to ask general usage questions, or look for answers here.
Post Reply
mqley
Veteran Member
Posts: 70
Joined: 2020-07-19 13:25
Contact:

Settings.

Post by mqley » 2020-10-14 09:56

Hi, I have a table for settings. I only want to be able to add one row to this table as its for settings only. So don't want to be able to ADD NEW to that. what would be the best way to achieve this? Thanks. Mark
Best Wishes,

Mark

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

Re: Settings.

Post by jsetzer » 2020-10-14 11:42

Maybe you should try something like this:

Code: Select all

function settings_init(&$options, $memberInfo, &$args)
{
  $options->AllowInsert = sqlValue("SELECT count(*) FROM settings") == 0 ? 1 : 0;	
  return TRUE;
}
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

mqley
Veteran Member
Posts: 70
Joined: 2020-07-19 13:25
Contact:

Re: Settings.

Post by mqley » 2020-10-14 12:09

Thats great. Is that a shorthand for the select? An if then ? - I like it. Thanks for this.
Best Wishes,

Mark

User avatar
zibrahim
Veteran Member
Posts: 137
Joined: 2020-01-28 18:30
Location: Malaysia

Re: Settings.

Post by zibrahim » 2020-10-14 14:04

Thanks mqley for asking about this and thanks Jan for the answer.
Actually I was looking for this solution as well. :D

And mqley, regarding your question about the shorthand, I found this
https://www.php.net/manual/en/language. ... arison.php
Scroll down to the "Ternary Operator " area. Hope this help.
Zala.
Appgini 24.10.1579, MacOS 14.3.1 Windows 11 on Parallels.

Post Reply