Docs For Class DataListSource

## 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

- author: Walter A. Boring IV <waboring@newsblob.com>

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

Direct descendents

Class | Description
--- | ---
ArrayDataListSource | This DataListSource child class gets the data from an external array
SQLDataListSource |

Variable Summary
array $_columns
mixed $_data
mixed $_data_index
mixed $_debug
mixed $_query_params
Method Summary
DataListSource 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_data_index ()
int get_limit ()
array() get_next_data_row ()
int get_offset ()
int get_orderby ()
int get_reverseorder ()
int get_searchby ()
int get_searchby_value ()
string get_search_type ()
array get_secondary_orderby ()
int get_simplesearch_modifier ()
int get_total_rows ()
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)
none set_debug ([mixed $level = FALSE])
void set_limit (mixed $limit)
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_secondary_orderby (mixed 0)
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 74)

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 65)

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 $_debug = FALSE (line 80)

debugging flag for debugging queries.

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

This holds various parameters relating

to the query of the data

Methods
Constructor DataListSource (line 86)

The constructor

DataListSource DataListSource ()
add_column (line 109)

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

Redefined in descendants as:

- PEARDB_DataObjectDataListSource::add_column() : Add a column of data to manage

do_prequery (line 198)

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:

- ArrayDataListSource::do_prequery() : This is a method that should be defined by the child class to do any pre-query type of things.
- CSVFILEDataListSource::do_prequery() : The prequery. We use this to read the file
- SQLDataListSource::do_prequery()

do_query (line 213)

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:

- ArrayDataListSource::do_query() : This function does the query
- CSVFILEDataListSource::do_query() : This function does the query
- SQLDataListSource::do_query() : Do the query to the DB and pull in all of the records locally.
- ADODBSQLDataListSource::do_query() : This is the function that does the data fetching, and sorting if needed.
- PEARSQLDataListSource::do_query() : This is the function that does the data fetching, and sorting if needed.
- PGSQLDataListSource::do_query()
- PEARDB_DataObjectDataListSource::do_query() : Perform the query on the database (executes DB_DataObject's ->find() method)

get_data_index (line 444)

This function returns the data_index value and increments it

int get_data_index ()

Redefined in descendants as:

- ArrayDataListSource::get_data_index() : This function returns the data_index value and increments it

get_limit (line 392)

This function gets the current value of the limit value

int get_limit ()
get_next_data_row (line 174)

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

array() get_next_data_row ()

Redefined in descendants as:

- ArrayDataListSource::get_next_data_row() : This function returns the next row of valid data.
- SQLDataListSource::get_next_data_row() : This function gets the next data row from the query()
- ADODBSQLDataListSource::get_next_data_row() : This function gets the next data row from the query()
- PEARSQLDataListSource::get_next_data_row() : This function gets the next data row from the query()
- PGSQLDataListSource::get_next_data_row() : This function gets the next data row from the query()
- PEARDB_DataObjectDataListSource::get_next_data_row() : Return the next row of the matching result set as an array.

get_offset (line 269)

This function returns the value of the offset

int get_offset ()
get_orderby (line 291)

This function returns the value of the orderby

int get_orderby ()
get_reverseorder (line 312)

This function returns the value of the reverseorder

int get_reverseorder ()
get_searchby (line 332)

This function returns the value of the searchby

int get_searchby ()
get_searchby_value (line 352)

This function returns the value of the search value

int get_searchby_value ()
get_search_type (line 413)

this function returns the current search type for the DataList query

string get_search_type ()
get_secondary_orderby (line 434)

This gets the list of secondary order by columns.

array get_secondary_orderby ()
get_simplesearch_modifier (line 372)

This function returns the value of the search value

int get_simplesearch_modifier ()
get_total_rows (line 236)

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

int get_total_rows ()
query (line 140)

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 185)

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_debug (line 477)

This function is used to set the debug level.

none set_debug ([mixed $level = FALSE])

- mixed $level

set_limit (line 382)

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_offset (line 258)

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 281)

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 302)

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 322)

This sets the column that we want to search from.

void set_searchby (int $search_col)

- int $search_col: offset

set_searchby_value (line 342)

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 403)

This function sets the search type (simple or advanced)

void set_search_type (string $search_type)

- string $search_type

set_secondary_orderby (line 424)

This method is used to set a secondary list of columns to order/sort by.

void set_secondary_orderby (mixed 0)

- mixed 0: - n numbers of column names to order by

set_simplesearch_modifier (line 362)

This sets the simple search modifier

void set_simplesearch_modifier (int $search_modifier)

- int $search_modifier: offset

set_total_rows (line 246)

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 226)

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:

- ArrayDataListSource::sort() : This method sorts our data array by the requested column order by. This could be expensive for HUGE arrays.

_is_column_sortable (line 458)

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

Documentation generated on Thu, 1 Sep 2005 17:05:36 -0700 by phpDocumentor 1.3.0RC3