DatabaseRecord
super: Object
A DatabaseRecord is a data structure that represent values to be used within the addRecord or updateRecord methods.
Events
-
Load() This event is called when the object becames available in the current runtime system.
-
Unload() This event is called when the object has been removed from the current runtime system (but not yet deallocated).
Methods
-
func bindNull(name: String) Bind null value.
-
func bindText(name: String, value: String) Bind String value.
-
func bindDouble(name: String, value: Float) Bind Double value.
Examples
This example assumes that you have a valid connection with a Database. That DB database object should contain an images table (id int column as primary key and a data column as BLOB):
// INSERT EXAMPLE
// extract PNG data from and Image
var image = image1.PNGRepresentation();
// prepare database record
var rec = DatabaseRecord();
rec.bindInt("id", 1);
rec.bindData("data", image);
// insert record into table images
DB.addRecord(rec, "images");
if (DB.isError) Console.write(DB.errorMessage);
// UPDATE EXAMPLE
// extract PNG data from and Image
var image = image1.PNGRepresentation();
// prepare database record
var rec = DatabaseRecord();
rec.bindInt("id", 1);
rec.bindData("data", image);
// update record into table images WHERE id=1
DB.updateRecord(rec, "images", "id=1");
if (DB.isError) Console.write(DB.errorMessage);