Menu

## Pagination
in package

Pagination.php : 20

Pagination class

This class is used to generate pagination links for a given set of results.

### Table of Contents

#### Properties

$currentNumberOfRecords : int
  Represents the current number of records in the pagination.
$currentPage : int
  Represents the current page number.
$currentPageDefinedByUser : int|null
$db : Db
  Database connection object.
$numberOfPages : int
  Represents the number of pages in the pagination.
$paginationOptions : PaginationOptions
  Options
$recordsPerPage : int
$totalRecordsCount : int
  The total number of records in the pagination.
$view : View
  Represents a Pagination object.

#### Methods

__construct() : mixed
  Constructor for the Pagination class.
fetch() : mixed
  Fetches the next row from a result set and returns it according to the $fetch_parameters format
fetchAll() : mixed
  Fetches all rows from a result set and return them according to the $fetch_parameters format
getCurrentNumberOfRecords() : int
  Returns the current number of records.
getCurrentPage() : int
  Retrieves the current page number.
getDb() : Db
  Get the database instance.
getNumberOfPages() : int
  Returns the number of pages.
getRecordsPerPage() : int
  Get the number of records to display per page.
getTotalRecordsCount() : int
  Returns the total number of records in the dataset.
pagine() : string
  Build pagination
select() : self
  Selects data from the database.
setCurrentPage() : void
  Sets the current page number and overrides the querystring.
setOptions() : void
  Sets the options for pagination.
setRecordsPerPage() : self
  Sets the number of records to display per page.
removePreviousQuerystring() : string
  Removes any previous querystring parameters from the URL.

### Properties

#### $currentNumberOfRecords

Pagination.php : 43

Represents the current number of records in the pagination.

`private int $currentNumberOfRecords`

#### $currentPage

Pagination.php : 50

Represents the current page number.

`private int $currentPage`

The current page number.

#### $currentPageDefinedByUser

Pagination.php : 52
`private int|null $currentPageDefinedByUser = null`

#### $db

Pagination.php : 25

Database connection object.

`private Db $db`

#### $numberOfPages

Pagination.php : 59

Represents the number of pages in the pagination.

`private int $numberOfPages`

The number of pages in the pagination.

#### $paginationOptions

Pagination.php : 31

Options

`private PaginationOptions $paginationOptions`

The options for the pagination.

#### $recordsPerPage

Pagination.php : 64
`private int $recordsPerPage = 10`

The number of records to display per page.

#### $totalRecordsCount

Pagination.php : 69

The total number of records in the pagination.

`private int $totalRecordsCount = 0`

#### $view

Pagination.php : 38

Represents a Pagination object.

`private View $view`

The view object associated with the Pagination.

### Methods

#### __construct()

Pagination.php : 77

Constructor for the Pagination class.

`public __construct(Db $db, PaginationOptions $paginationOptions, View $view, int $recordsPerPage) : mixed`

##### Parameters

$db : Db

  The database connection object.

$paginationOptions : PaginationOptions

  The pagination options object.

$view : View
$recordsPerPage : int

#### fetch()

Pagination.php : 152

Fetches the next row from a result set and returns it according to the $fetch_parameters format

`public fetch([int $fetch_parameters = PDO::FETCH_OBJ ]) : mixed`

##### Parameters

$fetch_parameters : int = PDO::FETCH_OBJ

  The PDO fetch style record options

##### Return values

mixed —

The next row or false if we reached the end

#### fetchAll()

Pagination.php : 163

Fetches all rows from a result set and return them according to the $fetch_parameters format

`public fetchAll([int $fetch_parameters = PDO::FETCH_OBJ ]) : mixed`

##### Parameters

$fetch_parameters : int = PDO::FETCH_OBJ

  The PDO fetch style record options

##### Return values

mixed —

The rows according to PDO fetch style or false if no record

#### getCurrentNumberOfRecords()

Pagination.php : 293

Returns the current number of records.

`public getCurrentNumberOfRecords() : int`

##### Return values

int —

The current number of records.

#### getCurrentPage()

Pagination.php : 303

Retrieves the current page number.

`public getCurrentPage() : int`

##### Return values

int —

The current page number.

#### getDb()

Pagination.php : 329

Get the database instance.

`public getDb() : Db`

##### Return values

Db —

The database instance.

#### getNumberOfPages()

Pagination.php : 349

Returns the number of pages.

`public getNumberOfPages() : int`

##### Return values

int —

The number of pages.

#### getRecordsPerPage()

Pagination.php : 359

Get the number of records to display per page.

`public getRecordsPerPage() : int`

##### Return values

int —

The number of records per page.

#### getTotalRecordsCount()

Pagination.php : 390

Returns the total number of records in the dataset.

`public getTotalRecordsCount() : int`

##### Return values

int —

The total number of records.

#### pagine()

Pagination.php : 175

Build pagination

`public pagine(string $url) : string`

##### Parameters

$url : string

  The base URL for the pagination links.

##### Return values

string —

The HTML for the pagination links.

#### select()

Pagination.php : 99

Selects data from the database.

`public select(string $from, string|array<string|int, string> $fields[, array<int|string, mixed>|string $where = [] ][, array<string, bool|int|string> $parameters = [] ][, bool|string $debug = false ]) : self`

##### Parameters

$from : string

  The SQL FROM statement with optional joins. Example: 'table1 INNER JOIN table2 ON table1.id = table2.id'.

$fields : string|array<string|int, string>

  The columns to select. Can be a string or an array of strings.

$where : array<int|string, mixed>|string = []

  The WHERE clause. Can be a string or an array of conditions. If it's an array, the conditions will be joined with AND.

$parameters : array<string, bool|int|string> = []

  An associative array of parameter names and values.

$debug : bool|string = false

  false, true or silent. false: the production mode. true: The query is displayed. 'silent': The query is registered then can be displayed using the getDebug() method.

##### Return values

self

#### setCurrentPage()

Pagination.php : 339

Sets the current page number and overrides the querystring.

`public setCurrentPage(int $currentPage) : void`

##### Parameters

$currentPage : int

  The current page number.

#### setOptions()

Pagination.php : 369

Sets the options for pagination.

`public setOptions(array<string, bool|string> $options) : void`

##### Parameters

$options : array<string, bool|string>

  An array of options for pagination.

#### setRecordsPerPage()

Pagination.php : 379

Sets the number of records to display per page.

`public setRecordsPerPage(int $recordsPerPage) : self`

##### Parameters

$recordsPerPage : int

  The number of records to display per page.

##### Return values

self

#### removePreviousQuerystring()

Pagination.php : 401

Removes any previous querystring parameters from the URL.

`private removePreviousQuerystring(string $url) : string`

##### Parameters

$url : string

  The URL to remove the querystring from

##### Return values

string —

The updated URL

## Search results