MongoDB Pagination 0.3

2,470 views

Published on

MongoDB Pagination is the PHP Pagination tool developed by Techunits and has been used by many of it's partners; e.g. Buzzers.co.za, Trivian Mobile API, CelebRise Network etc.

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,470
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
12
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

MongoDB Pagination 0.3

  1. 1. MongoDB Pagination 0.3 From Presented By: Sougata Pal (Skall) [email_address] November 28, 2011 Download Link: https://sourceforge.net/projects/mongopagination/
  2. 2. MongoDB Pagination 0.3 Introduction to MongoDB Pagination MongoDB Pagination is the PHP Pagination tool developed by Techunits and has been used by many of it's partners; e.g. Buzzers.co.za, Trivian Mobile API, CelebRise Network etc. MongoDB Pagination is already been indexed by Mongo team on their official site as follows: http://www.mongodb.org/display/DOCS/PHP+Libraries%2C+Frameworks%2C+and+Tools
  3. 3. MongoDB Pagination 0.3 Initialize MongoDB Pagination /* Include MongoDB Pagination Library into your code */ require_once('MongoPagination/MongoPagination.php'); /* Connect to MongoDB server */ $mongoConn = new Mongo(); $mongoHandler = $mongoConn->testDatabase; /* Initiate MongoDB Pagination Object with MongoConnection Handler */ $pagination = new MongoPagination($mongoHandler); Note: Once MongoDB Pagination Object is Initiated you can directly pass MongoDB find(), sort() parameters into it. You wil not require any abstrcted layer to pass through.
  4. 4. MongoDB Pagination 0.3 MongoDB Pagination with Limit $limit = 20; $pagination->setQuery(array( '#collection' => 'testCollection', '#find' => array( 'key' => 'mykey' ), '#sort' => array( 'created' => -1 ), ), $limit); /* Paginate the result with repect to the parameter you have passed via setQuery() $dataSet = $pagination->Paginate(); Note: The resultset will contain follwing fields witj only limit is passed into setQuery, $dataset['dataset'] = "ARRAY / STRING - raw data array/string" $dataset['totalItems'] = "INTEGER - total number of documents available with respect to the query"
  5. 5. MongoDB Pagination 0.3 MongoDB Pagination with Limit $itemsPerPage = 5; $currentPage = 1; $pagination->setQuery(array( '#collection' => 'testCollection', '#find' => array( 'key' => 'mykey' ), '#sort' => array( 'created' => -1 ), ), $currentPage, $itemsPerPage); $dataSet = $pagination->Paginate(); $page_links = $pagination->getPageLinks(); Note: The resultset will contain follwing info, $dataset['dataset'] = "ARRAY / STRING - raw data array/string" $dataset['totalPages'] = "INTEGER - total pages calculated with respect to $itemsPerPage" $dataset['totalItems'] = "INTEGER - total number of documents available with respect to the query"
  6. 6. MongoDB Pagination 0.3 Thank you for your valuable time Developers Email: [email_address] Community Discussion: [email_address] Download Link: https://sourceforge.net/projects/mongopagination/

×