1
Questions / Code snippets usage for Page Events
I have been trying to implement an automatic update on a field without success. I have a table “equipments” that has the fields: “code” and “type” (see bellow). The field “type” is always a combination of two letters, like “EP” or “PR”. I want to generate a sequential code field value after the user has entered the type. For that I need to get an array with all the code values for the type entered. I have been using the page events feature in PHPRad adding the code bellow to the equipments table in the AfterAdd session, but it doesn't seem to work. How to use the code snippets correctly for that? Thanks
Table:
equipments
-----------------
| code | type |
-----------------
| EP-001 | EP |
| PR-001 | PR |
| PR-002 | PR |
Code:
$params = array($rec_id);
$codes = $db->rawQuery("SELECT code FROM equipments WHERE type = '" . $modeldata['type'] . "'", $params);