Control insert into table at a day

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
wfouad
User
Posts: 10

Control insert into table at a day

Post by wfouad »

How do I control the number of records insert for a particular table during the day depending on level security.


mobhar
User
Posts: 11905

Post by mobhar »

Similar to this topic: http://www.hkvforums.com/viewtopic.php?f=4&t=32363

For checking user level security, then all you have to do is by adding the "if - else" control block.

For example:
// this code belongs to the "Page_Load" server event of the "Add Page".
function Page_Load() {
$levelid = CurrentUserLevel();
$val = ew_ExecuteScalar("SELECT COUNT(*) FROM YourTable WHERE YourUserLevelField = ".$levelid." AND YourDateField = '".date("Y-m-d")."'");
if ($levelid == 1 && $val >= 10) {
$this->setFailureMessage("Sorry, you are limited to entry 10 records for today!");
$this->Page_Terminate("YourTablelist.php");
} elseif ($levelid == 2 && $val >= 20) {
$this->setFailureMessage("Sorry, you are limited to entry 20 records for today!");
$this->Page_Terminate("YourTablelist.php");
} else {
// ... and so forth ...
}
}


Post Reply