Skip to content

Commit

Permalink
Better name forPage arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
elpete committed Mar 13, 2017
1 parent c396c98 commit 0037cdd
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions models/Query/Builder.cfc
Expand Up @@ -1160,10 +1160,23 @@ component displayname="Builder" accessors="true" {
return this;
}

public Builder function forPage( required numeric page, required numeric limitValue ) {
arguments.limitValue = arguments.limitValue > 0 ? arguments.limitValue : 0;
offset( arguments.page * arguments.limitValue - arguments.limitValue );
limit( arguments.limitValue );
/**
* Helper method to calculate the limit and offset given a page number and count per page.
*
* @pageNumber The page number to retrieve
* @pageCount The number of records per page.
*
* @return qb.models.Query.Builder
*/
public Builder function forPage(
required numeric pageNumber,
required numeric pageCount
) {
arguments.pageCount = arguments.pageCount > 0 ? arguments.pageCount : 0;
offset( arguments.pageNumber * arguments.pageCount - arguments.pageCount );
limit( arguments.pageCount );
return this;
}
return this;
}

Expand Down

0 comments on commit 0037cdd

Please sign in to comment.