Results Results(
string
$sql, [string
$param_prefix = ''], [string
$default_order = ''], [integer
$limit = NULL], [string
$count_sql = NULL], [boolean
$init_page = true], NULL|string
6
)
|
|
Constructor
Parameters:
|
NULL|string |
6: |
SQL query used to count the total # of rows (if NULL, we'll try to COUNT(*) by ourselves) |
|
string |
$sql: |
SQL query |
|
string |
$param_prefix: |
prefix to differentiate page/order params when multiple Results appear one same page |
|
string |
$default_order: |
default ordering of columns (special syntax) if not specified in the URL params example: -A-- will sort in ascending order on 2nd column example: ---D will sort in descending order on 4th column |
|
integer |
$limit: |
number of lines displayed on one page (0 to disable paging; null to use $UserSettings/results_per_page) |
|
string |
$count_sql: |
SQL to get the total count of results |
|
boolean |
$init_page: |
|
Information Tags:
| Todo: | we might not want to count total rows when not needed... |
| Todo: | fplanque: I am seriously considering putting $count_sql into 2nd or 3rd position. Any prefs? |
| Todo: | dh> We might just use "SELECT SQL_CALC_FOUND_ROWS ..." and "FOUND_ROWS()"..! - available since MySQL 4 - would save one query just for counting! |
integer callback_group_by_obj_prop(
array
$row_a, array
$row_b, [integer
$depth = 0]
)
|
|
Callback, to sort Result::$rows according to Result::$group_by_obj_prop.
Parameters:
|
array |
$row_a: |
DB row for object A |
|
array |
$row_b: |
DB row for object B |
|
integer |
$depth: |
Depth, used internally (you can group on a list of member properties) |
void count_total_rows(
[
$sql_count = NULL]
)
|
|
Count the total number of rows of the SQL result (all pages)
This is done by dynamically modifying the SQL query and forging a COUNT() into it.
Parameters:
Information Tags:
| Todo: | allow overriding? |
| Todo: | handle problem of empty groups! |
Redefined in descendants as:
int display(
[array|NULL
$display_params = NULL], [array
$fadeout = NULL]
)
|
|
Display paged list/table based on object parameters
This is the meat of this class!
Parameters:
|
array|NULL |
$display_params: |
|
|
array |
$fadeout: |
Fadeout settings array( 'key column' => array of values ) or 'session' |
API Tags:
| Return: | # of rows displayed |
Display list/table body.
This includes groups and data rows.
API Tags:
void display_colselect(
)
|
|
Display the column selection
Display the filtering form
void display_first(
[
$page_url = '']
)
|
|
returns the link to the first page, if necessary
Parameters:
void display_functions(
)
|
|
Display the functions
Redefined in descendants as:
Display list/table head.
This includes list head/title and column headers. EXPERIMENTAL: also dispays <tfoot>
API Tags:
Redefinition of:
- Table::display_head()
- Display list/table head.
boolean display_if_empty(
[
$params = array()]
)
|
|
Template function: display message if list is empty
Parameters:
API Tags:
Redefined in descendants as:
void display_init(
[array
$display_params = NULL], [array
$fadeout = NULL]
)
|
|
Initialize things in order to be ready for displaying.
This is useful when manually displaying, i-e: not by using Results::display()
Parameters:
|
array |
$display_params: |
***please document*** |
|
array |
$fadeout: |
Fadeout settings array( 'key column' => array of values ) or 'session' |
Redefinition of:
- Table::display_init()
- Initialize things in order to be ready for displaying.
void display_last(
[
$page_url = '']
)
|
|
returns the link to the last page, if necessary
Parameters:
void display_nav(
string
$template
)
|
|
Display navigation text, based on template.
Parameters:
|
string |
$template: |
template: 'header' or 'footer' |
API Tags:
void display_next(
[
$page_url = '']
)
|
|
returns a link to next pages, if necessary
Parameters:
void display_option_area(
string
$option_name, string
$area_name, string
$option_title, string
$submit_title, [string
$default_folde_state = 'expanded']
)
|
|
Display options area
Parameters:
|
string |
$option_name: |
name of the option ( ma_colselect, tsk_filter....) |
|
string |
$area_name: |
area name ( colselect_area, filter_area ) |
|
string |
$option_title: |
option title |
|
string |
$submit_title: |
submit button title |
|
string |
$default_folde_state: |
default folde state when is empty in the session |
void display_prev(
[
$page_url = '']
)
|
|
returns a link to previous pages, if necessary
Parameters:
Display totals line if set.
Returns the first page number to be displayed in the list
array get_col_sort_values(
integer
$col_idx
)
|
|
Returns values needed to make sort links for a given column
Returns an array containing the following values:
- current_order : 'ASC', 'DESC' or ''
- order_asc : url to order in ascending order
- order_desc
- order_toggle : url to toggle sort order
Parameters:
|
integer |
$col_idx: |
column to sort |
Redefined in descendants as:
Get number of rows available for display
string get_order_field_list(
)
|
|
Returns order field list add to SQL query:
API Tags:
void get_page_ID_array(
)
|
|
Get an array of IDs for current page
API Tags:
Get a list of IDs for current page
API Tags:
Note: this function might actually not be very useful.
If you define ->Cache before display, all rows will be instantiated on the fly. No need to restart et go through the rows a second time here.
Parameters:
returns the last page number to be displayed in the list
void mergesort(
array
&$array, callback
$cmp_function
)
|
|
Merge sort. This is required to not re-order items when sorting for e.g. grouping at the end.
Parameters:
|
array |
&$array: |
List of items to sort |
|
callback |
$cmp_function: |
Sort function/method |
API Tags:
Increment and update all necessary counters before processing a new line in result set
integer order_callback_wrapper_objects(
$row_a,
$row_b
)
|
|
Wrapper method to http://www.php.net/usort, which instantiates objects and passed them on to the order callback.
Parameters:
integer order_callback_wrapper_rows(
$row_a,
$row_b
)
|
|
Wrapper method to http://www.php.net/usort, which passes the rows to the order callback.
Parameters:
void page_list(
$min,
$max, [
$page_url = '']
)
|
|
Returns the page link list under the table
Parameters:
void parse_col_content(
$content
)
|
|
Handle variable subtitutions for column contents.
This is one of the key functions to look at when you want to use the Results class.
- $var$
- £var£
- #var#
- {row}
- %func()%
- ¤func()¤
Parameters:
void query(
[
$create_default_cols_if_needed = true], [
$append_limit = true], [
$append_order_by = true], [
$query_title = 'Results::Query()']
)
|
|
Run the query now!
Will only run if it has not executed before.
Parameters:
|
|
$create_default_cols_if_needed: |
|
|
|
$append_limit: |
|
|
|
$append_order_by: |
|
|
|
$query_title: |
|
Redefined in descendants as:
Rewind resultset
Redefined in descendants as: