Creating the Insert TransactionCreating the Insert TransactionGetting startedFirst create, in your site root folder, a new file named "insert.php". Then, in the "index.php" file, insert a link named "Add", pointing to the record insertion page named "insert.php". To create a link, select the "Add" text, use your right mouse button and select the "insert.php" file from the list displayed by Dreamweaver.
Creating an Insert TransactionA transaction, in the tNG context, represents a basic operation on a database. Open the "insert.php" file and create an Insert Transaction. To do that, go to "ImpAKT2" tab from "Insert" panel and press the "tNG Insert From" button (first icon from the left).
Dreamweaver MX will display the transaction User Interface:
We will continue by explaining the parameters of the interface, to help you understand how it has to be configured for a correct functioning. Insert Transaction parametersTransaction Name: a unique name in the page context. A textual representation of the transaction in the source code and the Dreamweaver User Interface. Connection: the connection that will be used to execute this transaction Table: the table in which we want to insert some records. We will select "departments_dep" After inserting, Go To: a file to which the browser will be redirected if the transaction succeeded . We will select "index.php" to return to the main list. Form Fields: the list of all the columns in the selected table. For each column we can move it up/down, remove it or add them to the insert. For each column we must select or set:
The command adds also a UniVal trigger that validates the form input. ImpAKT 2 automatically gives a name to each new created transaction. However, this transaction name can be changed by the developer. Name this transaction "insertTransaction", then choose the "impaktbasics_conn" as connection and the "departments_dep" table as the transaction target table. Write the page to be loaded after the transaction is done (in our case being "index.php") in after inserting, Go To field. The "Unique Key Column" field must contain the "id_dep" field as this is the departments unique key. Then we choose the "name_dep" field as being required and "budget_dep" as being required and having a "Positive Float" field type. That will cause an error message if the user will try to insert a blank name department or a non numeric value for the budget. The Insert Transaction command user interface should look like in the picture below:
The "tNG Insert Form" command will generate the form, the Insert Transaction server behavior, the UniVAL trigger and the Handle error trigger. Also, a RollBack Insert trigger is generated. This last trigger will delete from the database any unnecessary data that might be written even if the Insert Transaction fails overall. We strongly recommend the use of this trigger for any new insert transaction created. This way you will protect your database from any possible disaster. Now press the "OK" button and save your "insert.php" file. |
Adobe acquired InterAKT
InterAKT has been acquired by Adobe.
Learn more
|