tangra logo
   
[ class tree: tangra_lib ] [ index: tangra_lib ] [ all elements ]
 

Class: Paginate_DB_Data

Source Location: /db/paginate_db_data.class.php

Class Paginate_DB_Data

Inherited Properties, Constants, and Methods
Inherited Properties Inherited Methods Inherited Constants

Inherited From Tangra_Class

Tangra_Class::get_class_name()
Alias of get_class(). Exist because of historical reasons.
Tangra_Class::__set()
Overides PHP built-in method and just throws exception if called. Purpose - to "forbid" autosetting of nonexisting class properties.

[ Top ]
Property Summary
unknown_type   $current_page   Holds current page index
boolean   $forgiving   If set to false some methods will throw exception if you try to fetch non existing page.
unknown_type   $page_size   Holds size of the page
unknown_type   $sql_count   SQL select statement for counting rows that match "where" clause
unknown_type   $sql_select   SQL select statement for selecting data
unknown_type   $total_pages   Holds count of currently available pages
unknown_type   $total_rows   Holds total number of rows

[ Top ]
Method Summary
Paginate_DB_Data   __construct()   Constructor
void   ask_for_forgivenes()   Check the forgivenes mode and throws exception if mode is false
integer   calculate_start()   Calculates start of current page
unknown   calculate_total_pages()   Calculates total pages
array   fetch_current_page()   Gathers current page rows
array   fetch_first_page()   Fetches first page
array   fetch_last_page()   Fetches last page
array   fetch_next_page()   Fetches next page
array   fetch_page()   Fetches page specified by $page
array   fetch_prev_page()   Fetches previous page
integer   get_current_page()   Returns current page
unknown   get_forgiving()   Gets forgiving mode
unknown   get_page_size()   Returns page size
string   get_sql_count()   Gets SQL statement that will be used to count rows matching the "where" clause
string   get_sql_select()   Gets SQL statement used to get actual data
integer   get_total_pages()   Returns total pages
integer   get_total_rows()   Returns total rows (current sql_count)
boolean   is_valid_page()   checks if $page is valid page index, i.e. there is such page
void   refresh()   Executes $sql_count and recalculates total rows and total pages
void   set_current_page()   Sets current page
void   set_forgiving()   Sets forgiving mode. If set to false some methods will throw exception if you try to fetch non existing page. If true - fetch* methods will guess some safe value. Default is false
void   set_page_size()   Sets page size
void   set_sql_count()   Sets SQL statement that will be used to count rows matching the "where" clause. Note that returned value have to be aliased with "as total_rows", otherwise you will get an exception
void   set_sql_select()   Sets SQL statement used to get actual data
void   set_total_pages()   Sets total pages for current sql count
void   set_total_rows()   Sets total rows.
array   _fetch_current_page()   Gathers current page rows

[ Top ]
Properties
unknown_type   $current_page = 0 [line 43]

Holds current page index

API Tags:
Access:  private


[ Top ]
boolean   $forgiving [line 35]

If set to false some methods will throw exception if you try to fetch non existing page.

API Tags:
Access:  private


[ Top ]
unknown_type   $page_size [line 59]

Holds size of the page

API Tags:
Access:  private


[ Top ]
unknown_type   $sql_count [line 81]

SQL select statement for counting rows that match "where" clause

API Tags:
Access:  private


[ Top ]
unknown_type   $sql_select [line 74]

SQL select statement for selecting data

API Tags:
Access:  private


[ Top ]
unknown_type   $total_pages [line 67]

Holds count of currently available pages

API Tags:
Access:  private


[ Top ]
unknown_type   $total_rows [line 51]

Holds total number of rows

API Tags:
Access:  private


[ Top ]
Methods
Constructor __construct  [line 92]

  Paginate_DB_Data __construct( integer $page_size, string $sql_select, string $sql_count, [boolean $forgiving = true]  )

Constructor

Parameters:
integer   $page_size:  Page size. How many rows will each page have
string   $sql_select:  SQL statement that will be used to set actual data
string   $sql_count:  SQL statement that will be used to count rows matching the "where" clause. Note that returned value have to be aliased with "as total_rows", otherwise you will get an exception
boolean   $forgiving:  If set to false some methods will throw exception if you try to fetch non existing page. If true - fetch* methods will guess some safe value. Default is false


[ Top ]
ask_for_forgivenes  [line 201]

  void ask_for_forgivenes( unknown_type $exception  )

Check the forgivenes mode and throws exception if mode is false

Parameters:
unknown_type   $exception: 

API Tags:
Access:  protected


[ Top ]
calculate_start  [line 273]

  integer calculate_start( )

Calculates start of current page


API Tags:
Internal:  
Access:  protected


[ Top ]
calculate_total_pages  [line 284]

  unknown calculate_total_pages( )

Calculates total pages


API Tags:
Internal:  
Access:  protected


[ Top ]
fetch_current_page  [line 318]

  array fetch_current_page( DB_Connection $dbc  )

Gathers current page rows

Parameters:
DB_Connection   $dbc: 

API Tags:
Return:  Returned rows
Access:  public


[ Top ]
fetch_first_page  [line 373]

  array fetch_first_page( DB_Connection $dbc  )

Fetches first page

Parameters:
DB_Connection   $dbc: 

API Tags:
Access:  public


[ Top ]
fetch_last_page  [line 387]

  array fetch_last_page( DB_Connection $dbc  )

Fetches last page

Parameters:
DB_Connection   $dbc: 

API Tags:
Access:  public


[ Top ]
fetch_next_page  [line 401]

  array fetch_next_page( DB_Connection $dbc  )

Fetches next page

Parameters:
DB_Connection   $dbc: 

API Tags:
Access:  public


[ Top ]
fetch_page  [line 442]

  array fetch_page( integer $page, DB_Connection $dbc  )

Fetches page specified by $page

Parameters:
integer   $page:  Page number
DB_Connection   $dbc: 

API Tags:
Access:  public


[ Top ]
fetch_prev_page  [line 421]

  array fetch_prev_page( DB_Connection $dbc  )

Fetches previous page

Parameters:
DB_Connection   $dbc: 

API Tags:
Access:  public


[ Top ]
get_current_page  [line 108]

  integer get_current_page( )

Returns current page


API Tags:
Access:  public


[ Top ]
get_forgiving  [line 190]

  unknown get_forgiving( )

Gets forgiving mode


API Tags:
See:  Paginate_DB_Data::set_forgiving
Access:  public


[ Top ]
get_page_size  [line 129]

  unknown get_page_size( )

Returns page size


API Tags:
Access:  public


[ Top ]
get_sql_count  [line 169]

  string get_sql_count( )

Gets SQL statement that will be used to count rows matching the "where" clause


API Tags:
Access:  public


[ Top ]
get_sql_select  [line 149]

  string get_sql_select( )

Gets SQL statement used to get actual data


API Tags:
Access:  public


[ Top ]
get_total_pages  [line 243]

  integer get_total_pages( )

Returns total pages


API Tags:
Access:  public


[ Top ]
get_total_rows  [line 223]

  integer get_total_rows( )

Returns total rows (current sql_count)


API Tags:
Access:  public


[ Top ]
is_valid_page  [line 357]

  boolean is_valid_page( integer $page  )

checks if $page is valid page index, i.e. there is such page

Parameters:
integer   $page: 

API Tags:
Internal:  
Access:  private


[ Top ]
refresh  [line 253]

  void refresh( DB_Connection $dbc  )

Executes $sql_count and recalculates total rows and total pages

Parameters:
DB_Connection   $dbc: 

API Tags:
Access:  public


[ Top ]
set_current_page  [line 331]

  void set_current_page( integer $current_page  )

Sets current page

Parameters:
integer   $current_page: 

API Tags:
Internal:  
Access:  protected


[ Top ]
set_forgiving  [line 179]

  void set_forgiving( boolean $forgiving  )

Sets forgiving mode. If set to false some methods will throw exception if you try to fetch non existing page. If true - fetch* methods will guess some safe value. Default is false

Parameters:
boolean   $forgiving: 

API Tags:
Access:  public


[ Top ]
set_page_size  [line 118]

  void set_page_size( integer $page_size  )

Sets page size

Parameters:
integer   $page_size: 

API Tags:
Access:  public


[ Top ]
set_sql_count  [line 159]

  void set_sql_count( string $sql_count  )

Sets SQL statement that will be used to count rows matching the "where" clause. Note that returned value have to be aliased with "as total_rows", otherwise you will get an exception

Parameters:
string   $sql_count: 

API Tags:
Access:  public


[ Top ]
set_sql_select  [line 139]

  void set_sql_select( unknown_type $sql_select  )

Sets SQL statement used to get actual data

Parameters:
unknown_type   $sql_select: 

API Tags:
Access:  public


[ Top ]
set_total_pages  [line 233]

  void set_total_pages( integer $total_pages  )

Sets total pages for current sql count

Parameters:
integer   $total_pages: 

API Tags:
Access:  public


[ Top ]
set_total_rows  [line 213]

  void set_total_rows( unknown_type $total_rows  )

Sets total rows.

Parameters:
unknown_type   $total_rows: 

API Tags:
Access:  protected


[ Top ]
_fetch_current_page  [line 296]

  array _fetch_current_page( DB_Connection $dbc  )

Gathers current page rows

Parameters:
DB_Connection   $dbc: 

API Tags:
Return:  Returned rows
Internal:  
Access:  protected


[ Top ]