[Solar-talk] Changes afoot: a new Model class
Paul M Jones
pmjones at ciaweb.net
Sat Feb 10 12:59:22 PST 2007
Hi all,
Based on Rodrigo's tips, I've implemented paging of related to-many
record fetching. As he correctly noted, it needs to go through
Record and Model, not RecordSet and Model (as I originally thought).
When you get a record with a to-many relationship, before you ask for
(say) the "comments" on that record, you can tell it what page of
comments to fetch.
$node = $nodes->fetch($id);
$node->setRelatedPage('comments', 1); // set page 1,
$node->dump($node->comments); // query and display 1st page
$node->setRelatedPage('comments', 2); // set page 2, clear
RecordSet
$node->dump($node->comments); // query and display 2nd page
Setting a new related page causes a new query to generate a new
RecordSet for the related property.
Paging is based on the $_paging set in the foreign model (in this
case, the "comments" model).
You can see the new code here:
<http://solarphp.com/svn/branches/model/Solar/Sql/Model.php>
<http://solarphp.com/svn/branches/model/Solar/Sql/Model/Record.php>
--
Paul M. Jones <http://paul-m-jones.com>
Solar: Simple Object Library and Application Repository
for PHP5. <http://solarphp.com>
Savant: The simple, elegant, and powerful solution for
templates in PHP. <http://phpsavant.com>
More information about the solar-talk
mailing list