dimoss
Well-Known Member
Hi
I post it here because for some reason I cannot post anymore in Standard forums.
I want to validate the count of records based on criteria. To accomplish that I have created a php validation:
With the above I want to limit the number of records to no more than 5 setting the validation to run on 'New' which means during the submission the query calculates the number of records already in the db table and returns true or false for the validation.
My question is how I could run the same validation also on 'Edit'?
Thanks for any help.
I post it here because for some reason I cannot post anymore in Standard forums.
I want to validate the count of records based on criteria. To accomplish that I have created a php validation:
PHP:
$db = JFactory::getDBO();
$player = '{fab_entries_na___player_raw}';
$assoc = '{fab_entries_na___assoc_raw}';
$gender = '{fab_entries_na___gender_raw}';
$query = "SELECT count(*) FROM fab_entries_na WHERE player = ". $db->quote($player)." AND gender = ". $db->quote($gender)." AND assoc = ". $db->quote($assoc);
$db->setQuery( $query );
$x = (int)$db->loadResult();
return $x < 5;
With the above I want to limit the number of records to no more than 5 setting the validation to run on 'New' which means during the submission the query calculates the number of records already in the db table and returns true or false for the validation.
My question is how I could run the same validation also on 'Edit'?
Thanks for any help.