Any suggestions on the best way to make a Demo version of your app? For instance, limit the number of records that can be added to all tables.
Thanks,
David
Creating a Demo of your app
Re: Creating a Demo of your app
Hi,
limit the number or records: I would probably create a new file which can be called from every /hooks/tablename.php file (use: require (...) and call the function (see below) in the tablename_before_insert function.
This new file contains a function which takes the tablename as argument.
Then the function tests how many records are in that table and rerturnd either TRUE, if the maximum record count is not reached yet or FALSE if the maximum record count in that table has been reached.
Of course, you could supply a second argument to the function which holds the maximum allowed records for that table.
Then the user will get an error when he tries to add a new record after the maximum number of records already exists.
Please make sure that your customer/demo user knows every time how many records can be placed in the table he is working on. Otherwise your application might leave a very bad impression. You could also supply a custom error (see my post here: viewtopic.php?f=7&t=1740&p=10906#p10906 ) telling why the insert did not work.
Olaf
limit the number or records: I would probably create a new file which can be called from every /hooks/tablename.php file (use: require (...) and call the function (see below) in the tablename_before_insert function.
This new file contains a function which takes the tablename as argument.
Then the function tests how many records are in that table and rerturnd either TRUE, if the maximum record count is not reached yet or FALSE if the maximum record count in that table has been reached.
Of course, you could supply a second argument to the function which holds the maximum allowed records for that table.
Then the user will get an error when he tries to add a new record after the maximum number of records already exists.
Please make sure that your customer/demo user knows every time how many records can be placed in the table he is working on. Otherwise your application might leave a very bad impression. You could also supply a custom error (see my post here: viewtopic.php?f=7&t=1740&p=10906#p10906 ) telling why the insert did not work.
Olaf
Some postings I was involved, you might find useful:
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view
-
- Veteran Member
- Posts: 101
- Joined: 2019-05-26 18:38
Re: Creating a Demo of your app
Much appreciated Olaf, I'll give it a spin. Thank you!
-
- Veteran Member
- Posts: 101
- Joined: 2019-05-26 18:38
Re: Creating a Demo of your app
Hello Olaf,
When/If you have the time, could you please provide an example of the code for the function that would limit the records? Also, I assume that the new file is a Table created with the "Required", attribute checked? If not, please explain if you would please.
Much appreciated,
David
When/If you have the time, could you please provide an example of the code for the function that would limit the records? Also, I assume that the new file is a Table created with the "Required", attribute checked? If not, please explain if you would please.
Much appreciated,
David
Re: Creating a Demo of your app
Hi,
as I do not know how your tables are named I can not really provide a code - even if I had the time.
I want to rephrase my suggestion: You should probably notify the user that no new record can be added _before_ he attempts adding one. This means, check if the user could add one more record and already show a message then (and also if the user actually tried to add one - of course).
No, the new file is not a table, but some .php file (you can name it as you like). This shows the problem of this approach: You can not give your code to any customer those could easily change the number of allowed - and that's not what you want .
The .php file should work like this: It contains a single function that can be called from every other file and receives the tablename, it's primary key field name and the number of records allowed.
All pseudo code:
call the function from the hooks/tablename.php function _before_insert:
and change the return value of hooks/tablename.php function _before_insert to:
Olaf
as I do not know how your tables are named I can not really provide a code - even if I had the time.
I want to rephrase my suggestion: You should probably notify the user that no new record can be added _before_ he attempts adding one. This means, check if the user could add one more record and already show a message then (and also if the user actually tried to add one - of course).
No, the new file is not a table, but some .php file (you can name it as you like). This shows the problem of this approach: You can not give your code to any customer those could easily change the number of allowed - and that's not what you want .
The .php file should work like this: It contains a single function that can be called from every other file and receives the tablename, it's primary key field name and the number of records allowed.
All pseudo code:
Code: Select all
function check_allowed_records($tablename, $pkfield, $numrecords){
$myreturnvalue = sqlValue("SELECT COUNT($pkfield) AS c FROM $tablename;");
if ($myreturnvalue < $numrecords){
$myreturnvalue = true;
} else {
$myreturnvalue = false;
}
return $myreturnvalue
}
Code: Select all
$myreturnvalue = function check_allowed_records(YOUR_TABLENAME, PRIMARYKEYFIELD_NAME, NUMBER_OF_ALLOWED_RECORDS)
Code: Select all
return $myreturnvalue
Some postings I was involved, you might find useful:
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view
-
- Veteran Member
- Posts: 101
- Joined: 2019-05-26 18:38
Re: Creating a Demo of your app
Olaf,
That's great, thank you very much for breaking it down for me. Helps a lot!
Best regards,
David
That's great, thank you very much for breaking it down for me. Helps a lot!
Best regards,
David