I've been playing a bit with other ways to access records from knop_database, so as an experiment I've implemented two things:
1. A record pointer that lets you loop through records with a while loop. ->field now returns data from the record that the record pointer points at (defaults to the first record so there's no change). ->nextrecord advances the record pointer until it reaches the last shown record (returns true while there are more records, false at the end).
2. ->size and ->get are now implemented so the found records ca be iterated (yea, I just realized that's all it takes to be able to iterate a ctype...). A new data type knop_databaserow has also been implemented and will be returned when iterating a database object, to allow simple access to individual fields from the row.
Examples:
var('db'=knop_database(-database='playground', -table='ramverktest')); // perform a search $db -> select;
// First a good old records loop records(-inlinename=$db->inlinename); field('firstname');' '; field('lastname'); '<br>'; /records;
// 1. testing the record pointer while($db -> nextrecord); // increment the record pointer // fetch data from the record the record pointer currently points at $db -> field('firstname');' ';$db -> field('lastname'); '<br>'; /while;
// 2. Iterating through the database object. iterate($db, var('row')); $row -> field('firstname');' ';$row -> field('lastname'); '<br>'; /iterate;
This is really nice.
Now the sad part. It's way too slow. Compared to the plain old records loop the record pointer method with ->nextrecord is 2 to 2.5 x slower, and the iterate method is 3 to 4 x slower. This is when I loop though a found set of 50 records.
Anyway, this is in te repository (still the param_navigation branch) in case you want to play with it a bit and maybe see if you can figure out how to optimize this.
-- Johan Sölve [FSA Member, Lasso Partner] Web Application/Lasso/FileMaker Developer MONTANIA SOFTWARE & SOLUTIONS http://www.montania.se mailto:joh-n@montania.se (spam-safe email address, replace '-' with 'a')
############################################################# This message is sent to you because you are subscribed to the mailing list <knop@lists.montania.se>. To unsubscribe, E-mail to: <knop-off@lists.montania.se> Send administrative queries to <knop-request@lists.montania.se> List archive http://www.nabble.com/Knop-Framework-Discussion-f29076.html Project homepage http://montania.se/projects/knop/ Google Code has the latest downloads at http://code.google.com/p/knop/
May 27
Jolle Carlestam Re: knop_database - accessing records
May 27, 2008; 17:15
Jolle Carlestam
Re: knop_database - accessing records
May 27
Jolle Carlestam Re: knop_database - accessing records
May 27, 2008; 17:18
Jolle Carlestam
Re: knop_database - accessing records
Search
Lasso Programming
This site manages and broadcasts several email lists pertaining to Lasso Programming and technologies related and used by Lasso developers. Sign up today!