MySQLi Insert Record

Adding new records to an existing table can be accomplished by using the Insert Record Server Behavior.

In the Server Behaviors panel (Window > Server Behaviors), click the plus (+) button and choose WebAssist > MySQLi > Data Management > Insert Record from the pop-up menu.

 

General Tab

 

     

  1. Use the Trigger select list and associated Trigger Dynamic Data button to select the event in which your record will be inserted.
  • Any Form Post: Any form posted to the current page that the server behavior is applied to triggers the data insert
  • Before Page Load: The data insert is triggered when the current page that the server behavior is applied to is loaded.
  • On Form Submit: Any form submitted on the same page that the server behavior is applied to trigger the data insert.
  • Button [button name] pressed: The server behavior is triggered if the specified button on the page is clicked.
  • Dynamic Data: Server-side code can be specified in the dynamic data interface (accessed through the lightning bolt) to create a trigger specific to your needs if one in the list does not meet your requirements
  1. Use the Connection and Insert Into Table menus to specify the database table into which the record should be inserted.
  2. Use the Save id in sassion field to specify a new session variable to be created after the new record is inserted. This session variable will hold the Record ID of the newly inserted record.
  3. Use the After inserting, to to field to specify a page to redirect to after the record is successfully inserted. Alternatively, the field can be left blank to stay on the current page.

Column Bindings Tab

The Column Bindings tab is where form values and/or other values (session, cookies, etc.) are designated for insertion into the table of your selection. Columns will be pre-populated for you based on the Table selected in the General tab.

  1. Enter the value you wish to insert for the corresponding Column. Select the column you wish to bind a value to, and either enter a static value, a variable, or use the associated Dynamic Data button to select a value from Bindings.
  2. Make a selection in the Submit as list to designate the data type you will be inserting. In most cases, this will be preset for you based on your column type. However, you can select any of the following:
    • Text
    • Integer
    • Double
    • Date
    • Checkbox Y,N
    • Checkbox 1,0
    • Checkbox -1,0
  3. Select the type of value used in the event that the Value you have selected is blank/null:
    • Empty String
    • Null
    • Db Default
    • Current Date
    • 0
    • N

After clicking OK, the Insert Record Server Behavior will be applied to the current page. Changes can be made by editing the MySQLi Insert Record Server Behavior from the Server Behaviors panel.