{"id":15640561,"url":"https://github.com/dcblogdev/pagination","last_synced_at":"2025-04-16T14:26:29.118Z","repository":{"id":6477670,"uuid":"7717766","full_name":"dcblogdev/pagination","owner":"dcblogdev","description":"Paginate record sets, not tied in directly to a database.","archived":false,"fork":false,"pushed_at":"2023-06-09T10:12:25.000Z","size":16,"stargazers_count":74,"open_issues_count":0,"forks_count":45,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-29T05:22:40.796Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dcblogdev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["dcblogdev"]}},"created_at":"2013-01-20T15:24:30.000Z","updated_at":"2025-03-21T16:09:36.000Z","dependencies_parsed_at":"2024-10-22T22:27:32.732Z","dependency_job_id":null,"html_url":"https://github.com/dcblogdev/pagination","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcblogdev%2Fpagination","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcblogdev%2Fpagination/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcblogdev%2Fpagination/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcblogdev%2Fpagination/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dcblogdev","download_url":"https://codeload.github.com/dcblogdev/pagination/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249250356,"owners_count":21237884,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T11:37:23.424Z","updated_at":"2025-04-16T14:26:29.090Z","avatar_url":"https://github.com/dcblogdev.png","language":"PHP","readme":"pagination\n==========\n\nPaginate record sets, not tied in directly to a database.\n\n## Usage\n1. include the class\n2. instantiate a new object pass in the number of items per page and the instance identifier, this is used for the GET parameter such as ?p=2\n3. pass the set_total method the total number of records\n4. show the records \n5. call the page_links method to create the navigation links\n\n ````php\n include('paginator.php');\n \n $pages = new Paginator('10','p');\n $pages-\u003eset_total('100'); //or a number of records\n \n //display the records here\n \n echo $pages-\u003epage_links();\n ````\n if using a database you limit the records by placing $pages-\u003eget_limit() in your query, this will limit the number of records\n \n ````php\n select * from table $pages-\u003eget_limit()\n ````\n \nby default the page_links method created links starting with ? this can be changed by passing in a parameter to the method:\n\n````php\necho $pages-\u003epage_links('\u0026');\n````\n\nThe method also allows you to pass in extra data such as a series of GET's\n\n````php\necho $pages-\u003epage_links('?','\u0026status='.$_GET['status'].'\u0026active='.$_GET['active']);\n```` \n \n## Database example\n\n````php\n//include the class\ninclude('paginator.php');\n\n//create new object pass in number of pages and identifier\n$pages = new Paginator('10','p');\n\n//get number of total records\n$stmt = $db-\u003equery('SELECT id FROM table');\n$total = $stmt-\u003erowCount();\n\n//pass number of records to\n$pages-\u003eset_total($total); \n\n$data = $db-\u003equery('SELECT * FROM table '.$pages-\u003eget_limit());\nforeach($data as $row) {\n    //display the records here\n}\n\n//create the page links\necho $pages-\u003epage_links();\n````\n\n## MVC example\n\nusing this class in an MVC environment its almost the same, only the database or dataset calls come from the model instead of the page directly.\n\nin the controller:\n\n````php\n\n//create a new object\n$pages = new Paginator('10','p');\n\n//set the total records, calling a method to get the number of records from a model\n$pages-\u003eset_total( $this-\u003e_model-\u003eget_all_count() );\n\n//calling a method to get the records with the limit set\n$data['records'] = $this-\u003e_model-\u003eget_all( $pages-\u003eget_limit() );\n\n//create the nav menu\n$data['page_links'] = $pages-\u003epage_links();\n\n//then pass this to the view, may be different depending on the system\n$this-\u003e_view-\u003erender('index', $data);\n````\n","funding_links":["https://github.com/sponsors/dcblogdev"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdcblogdev%2Fpagination","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdcblogdev%2Fpagination","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdcblogdev%2Fpagination/lists"}