Class DataListSource

Description

This is the base class for managing data for the DataList class. This abstracts away the underlying data layer from the DataList, so the data can come from multiple sources.

Most of the time the data will come from a data base such as Mysql or Oracle. This abstraction enables the data to also come from a tab delimited file, xml, php array

Located in Program_Root/widgets/data_list/DataListSource.inc (line 31)


	
			
Direct descendents
Class Description
SQLDataListSource
CSVFILEDataListSource This DataListSource child class gets the data from a CSV (comma seperated values) file on disk.
ArrayDataListSource This DataListSource child class gets the data from an external array
Variable Summary
Method Summary
void DataListSource ()
void add_column (string $title, string $data_name, [boolean $sortable = FALSE], [boolean $searchable = FALSE], [string $sortorder = "ASC"])
void do_prequery ()
boolean do_query ()
int get_limit ()
array() get_next_data_row ()
int get_offset ()
int get_orderby ()
int get_searchby ()
string get_search_type ()
void query (int $offset, int $limit, string $orderby, string $reverseorder, string $searchby, string $searchby_value, string $simplesearch_modifier, mixed $search_type)
boolean row_filter (array &$row_data)
void set_limit (mixed $limit)
void set_not_found_message (string $mesg)
void set_offset (int $offset)
void set_orderby (int $orderby)
void set_reverseorder (int $order)
void set_searchby (int $search_col)
void set_searchby_value (int $search_value)
void set_search_type (string $search_type)
void set_simplesearch_modifier (int $search_modifier)
void set_total_rows (int $num)
void sort ()
boolean _is_column_sortable (string $data_name)
Variables
array $_columns = array() (line 39)

The column descriptions for the data we are working on

mixed $_data = array() (line 79)

A placeholder for data that is read/built and stored locally. Not all data sources have to use this.

Each entry in the array corresponds to 1 row of data.

mixed $_data_index = 0 (line 70)

Holds the index into the array of data

so we can keep track of where we are when we are walking the array (only usefull for non DB children)

mixed $_not_found_message = "No data was found" (line 45)

This is the message displayed when no data

was retrieved from the database

mixed $_query_params = array("num_total_rows" => 0,
"offset" => 0,
"limit" => -1,
"orderby" => '',
"reverseorder" => '',
"searchby" => '',
"searchvalue" => '',
"searchmodifier" => '',
"searchtype" => 'simple')
(line 53)

This holds various parameters relating

to the query of the data

Methods
Constructor DataListSource (line 85)

The constructor

void DataListSource ()
add_column (line 108)

Add a column of data to manage

void add_column (string $title, string $data_name, [boolean $sortable = FALSE], [boolean $searchable = FALSE], [string $sortorder = "ASC"])
  • string $title:

    - the title of the column

  • string $data_name:

    - the data value name

  • boolean $sortable:

    - is the column sortable? default: FALSE

  • boolean $searchable:

    - is the column searchable default: FALSE

  • string $sortorder:

    - the sort order (ASC, DESC) default: ASC

do_prequery (line 197)

This is a method that should be defined by the child class to do any pre-query type of things.

Such as building a sql query string for a DB, or checking to make sure the file on disk exists if the source is a file on disk.

void do_prequery ()

Redefined in descendants as:
do_query (line 212)

This is the function that does the data fetching, and sorting if needed.

If the source is a sql database, this is where the query gets called. This function doesn't actually read the data from the DB yet. That is what get_next_data_row() does.

  • return:

    - the query passed/failed.

boolean do_query ()

Redefined in descendants as:
get_data_index (line 442)

This function returns the data_index value and increments it

int get_data_index ()

Redefined in descendants as:
get_limit (line 411)

This function gets the current value of the limit value

int get_limit ()
get_next_data_row (line 173)

This function gets the next data row from the query()

array() get_next_data_row ()

Redefined in descendants as:
get_not_found_message (line 245)

This function is used to get the message displayed when no data is found

string get_not_found_message ()
get_offset (line 288)

This function returns the value of the offset

int get_offset ()
get_orderby (line 310)

This function returns the value of the orderby

int get_orderby ()
get_reverseorder (line 331)

This function returns the value of the reverseorder

int get_reverseorder ()
get_searchby (line 351)

This function returns the value of the searchby

int get_searchby ()
get_searchby_value (line 371)

This function returns the value of the search value

int get_searchby_value ()
get_search_type (line 432)

this function returns the current search type for the DataList query

string get_search_type ()
get_simplesearch_modifier (line 391)

This function returns the value of the search value

int get_simplesearch_modifier ()
get_total_rows (line 255)

This returns the total number of rows in our entire data set

int get_total_rows ()
query (line 139)

The main Query function.

This function is responsible for doing any data prefetching from a db,file and doing any sorting and searching on it depending on the values passed in from the DataList object

void query (int $offset, int $limit, string $orderby, string $reverseorder, string $searchby, string $searchby_value, string $simplesearch_modifier, mixed $search_type)
  • int $offset:

    - the offset into the data set

  • int $limit:

    - the # of rows to get

  • string $orderby:

    - the column to order the data by

  • string $reverseorder:

    - order in asc or reverse?

  • string $searchby:

    - the column in the dataset to search by

  • string $searchby_value:

    - the value to look for

  • string $simplesearch_modifier:

    - the simple search modifier.

row_filter (line 184)

This is called by the DataList object to allow us a chance to run the next row through a filter

  • return:

    - TRUE = allow the row. FALSE = drop it.

boolean row_filter (array &$row_data)
  • array &$row_data:

    - the row to run through the filter

set_limit (line 401)

This function is used to set

the limit value, which limits the # of rows of data to allow to return

void set_limit (mixed $limit)
set_not_found_message (line 235)

This function is used to set the message displayed when no data is found

void set_not_found_message (string $mesg)
  • string $mesg
set_offset (line 277)

This sets the offset value and resets the index into the data array (in non DB children)

void set_offset (int $offset)
  • int $offset:

    offset

set_orderby (line 300)

This sets the orderby column name.

This corresponds to the column that wants to be sorted/ordered, but not the actual direction (asc, desc)

void set_orderby (int $orderby)
  • int $orderby:

    offset

set_reverseorder (line 321)

This sets the flag that tells us the direction in which to order the orderby column.

void set_reverseorder (int $order)
  • int $order:

    offset

set_searchby (line 341)

This sets the column that we want to search from.

void set_searchby (int $search_col)
  • int $search_col:

    offset

set_searchby_value (line 361)

This sets the data that we want to search for.

void set_searchby_value (int $search_value)
  • int $search_value:

    offset

set_search_type (line 422)

This function sets the search type (simple or advanced)

void set_search_type (string $search_type)
  • string $search_type
set_simplesearch_modifier (line 381)

This sets the simple search modifier

void set_simplesearch_modifier (int $search_modifier)
  • int $search_modifier:

    offset

set_total_rows (line 265)

This is used to set the total # of rows we have in our data set

void set_total_rows (int $num)
  • int $num
sort (line 225)

A generic method API that can be used at the bottom half of the do_query() method to sort data that is stored locally. This is only needed when the source is a non database.

It should operate on the $this->_data array

void sort ()

Redefined in descendants as:
_is_column_sortable (line 456)

This function determines if the column associated w/ a data_name is sortable or not

  • return:

    - is that column sortable?

boolean _is_column_sortable (string $data_name)
  • string $data_name:

    - the data_name filed in the _columns array to look for

Documention generated on Thu, 31 Jul 2003 18:32:23 -0700 by phpDocumentor 1.2.0