Limit and offset related model

Hi All,

I have Header and Detail objects, where one Header has many Detail (define in details relations). To display details for each header, I use

foreach($model->details as $detail) {



Now, I want to print the form, and each page consists only 15 rows of details. Normally, I will run foreach to capture the details into array, then using array index manipulation to get those rows to be printed. Being lazy, I think I should be able to use limit and offset to achieve that with simple and efficient manner.

Anyone can help on how to do this? And What do you think performance wise? use $model->details and put it in an array will cost me one sql query, but using limit and offset should make n sql calls but should be quicker since there is limit and offset in place.