A database insert operation (under the comment text "Insert new records" in the previous example) would look like:
database phbook action="insert";
The operation loops through the "keys" variable, of which each element points to a record in the matrix (matrix%key). An insert query will be generated for each record. The field list of the insert query is obtained from the "fields" variable, and the value list is from the matrix record (indexed by the field name from the "fields" variable.)
The field specified in the "keyfield" variable will obtained from the database platform. (If the key can be generated automatically, it will be omitted from the field list and value list. If the key needs to be obtained explicitly, BEE will do so and include the field and value to the insert query accordingly.)
The query would look like "insert into table (field1, field2, ... ) values (value1, value2, ... )".
In the above example, the Birthday values will be encoded with the Conversion "strtotime" as specified in the phbook%encode:Birthday element. This will automatically convert the date string (e.g. "10 Jan, 2003") into the timestamp format.
The operation will stop at the first error. The error code and error message are contained in status%database and message%database respectively. (For the integrity of the database object, you will have them in the database object as well. In our example, they are phbook%status and phbook%message.)
|