Is this possible in Lua?
In other languages, I'm used to fetching a record as an array/table and being able to just grab the appropriate field from that set using variables. Something like this:
$field1 = "fldSomething"; $field2 = "fldSomethingElse"; $record = dbFetch(" SELECT * FROM `tblTable` WHERE fldFoo = 'Bah' "); echo $field1 . " = " . $record[$field1]; echo $field2 . " = " . $record[$field2];
But in Lua, records don't seem to be returned as assoc tables and I'm struggling to find a workaround?
I.e. say I'm iterating records like this:
for result in db:nrows( [[SELECT * FROM `tblTable` WHERE fldFoo = "Bah";]] ) do print("fldSomething = " .. result.fldSomething ) end
How would I amend that print statement if fldSomething isn't a hard-coded name?
local field1 = "fldSomething" for result in db:nrows( [[SELECT * FROM `tblTable` WHERE fldFoo = "Bah";]] ) do -- I obviously can't just do result.field1 here, because field1 isn't a property of result... print(field1 .. " = " .. result.field1 ) end