|
|
A DBI Record. When utilizing `foreach' or `populate' methods
of a DBIResult object, you can pass an optional Object cloned from DBIRecord.
This object will be populated with the row contents making it possible to
write objects that represent your SQL results. A simple example would be:
Person := DBIRecord clone do (fullName := method(firstName.." "..lastName))
q := conn query("SELECT id, firstName, lastName FROM people")
q foreach(Person, p, writeln("Name = ", p fullName))
As you can see, fullName was not in the SQL query, however, a dynamic method
in your Person class.
DBIRecord in and of itself provides no real functionality. It simply acts
as an Object and stores the values from the SQL query into a Map. You can
access the field information:
o := r populate(Person)
o firstName // would retrieve the firstName value of the SQL query
o setFirstName("John") // would update the object's firstName value to be John
Do not confuse the above example as updating the actual database. The call
to setFirstName only updates the objects representation of firstName.
|