Page 1 of 1
Settings.
Posted: 2020-10-14 09:56
by mqley
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
Re: Settings.
Posted: 2020-10-14 11:42
by jsetzer
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;
}
Re: Settings.
Posted: 2020-10-14 12:09
by mqley
Thats great. Is that a shorthand for the select? An if then ? - I like it. Thanks for this.
Re: Settings.
Posted: 2020-10-14 14:04
by zibrahim
Thanks mqley for asking about this and thanks Jan for the answer.
Actually I was looking for this solution as well.
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.