Wizards Toolkit Documentation

BrowsePDO.php

Browse Data functionality - Wizards Toolkit low-code development library

All rights reserved.

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Tags
author
Programming Labs
license
All rights reserved
version
2.0

Table of Contents

wzSearchReplaceRow()  : mixed
wzSearchCounter()  : string
Number of values to replace in a data row
wzFillSuppressArray()  : void
Fill Suppress Array
wzColSuppressed()  : bool
Pass in Column Name to see if it is suppressed due to wzFillSuppressArray
wzFilterRequest()  : string
This function manages Filter requests on browse boxes.
wzModifyOrderBy()  : string
Alter ORDER BY based on header sort options.
wzFillBrowsePage()  : string
Fill Browse Page: this uses any SQL SELECT statement to build a full page showing the result set.
wzBuildDataBrowse()  : string
Build Data Browse in HTML table with sortable columns and option to show add, edit and delete button/features.
wzBuildFooter()  : string
Build Footer
wzSetHeaderSort()  : void
Declare Columns to be sortable in browse list.
wzBuildColHeader()  : string
Build Column Header
wzBrowseExport()  : html
This will export the results to CSV and show a download option instead of showing SQL as a browse result set.
wzBrowseExportXML()  : html
This will export the results to XML and show a download option instead of showing SQL as a browse result set.

Functions

wzSearchReplaceRow()

wzSearchReplaceRow ( mixed  $fncSearch , mixed  $fncReplace ) : mixed
Parameters
$fncSearch : mixed
$fncReplace : mixed
Return values
mixed

wzSearchCounter()

Number of values to replace in a data row

wzSearchCounter () : string
Tags
global

string $pgSearchReplaceRowCntr

Return values
string

$pageSearchReplaceRowCntr which holds count for managing $gloRowChangeArray values

wzFillSuppressArray()

Fill Suppress Array

wzFillSuppressArray ( string  $fncColumnName ) : void

Add columns to this array that you do not want to show in BrowsePDO result list. This can be useful for sort order functionality.

Parameters
$fncColumnName : string
Tags
global

array $gloSuppressColumnArray

Return values
void

wzColSuppressed()

Pass in Column Name to see if it is suppressed due to wzFillSuppressArray

wzColSuppressed( string  $fncColumnName ) : bool

This function is called from wzBuildDataBrowse, wzBrowseExport and wzBrowseExportXML. If column is suppressed it will not be shown.

Parameters
$fncColumnName : string
Tags
global

array $gloSuppressColumnArray

Return values
bool

true if column is in $gloSuppressColumnArray array

wzFilterRequest()

This function manages Filter requests on browse boxes.

wzFilterRequest( string  $fncFilterName [, string  $fncPage = '' ] ) : string

Browse Data pages often have filter options. Pass in to this function the name of the form field that contains the filter and optionally the Page name. A session variable is created using a combination Page name and Filter name.

If the page was called with Reset=Y then it clears the session variable for this filter. Otherwise it checks to see if the filter has just been set. If so it saves the information in a session variable for the same name as the filter form field and returns the value that was chosen. If the filter was not just set, this function checks the session variable of same name to see if it was previously set and if so uses that value. This way the AJAX calls for page navigation and header sorts will retain prior filter settings. By passing same FilterName and PageName on multiple pages, can share filter across multiple pages.

Here is an example:
$pgProjUID = wzFilterRequest('wzProjectsUID','pageName');
if ($pgProjUID != ''):
    $pgSQL .= ' AND p.UID = ' . $pgProjUID;
endif;

Parameters
$fncFilterName : string
$fncPage : string = ''

which defaults to PHP_SELF

Return values
string

$fncResult containing filter value

wzModifyOrderBy()

Alter ORDER BY based on header sort options.

wzModifyOrderBy ( string  $fncSQL , mixed  $fncTableId ) : string

This is called by wzBuildDataBrowse, wzBrowseExport and wzBrowseExportXML and should not be called directly.

wzSetHeaderSort is used to make sortable headers in browse list generated by wzBuildDataBrowse. When the header is clicked, it calls a JavaScript function which passes parameters to a PHP page and this function is used to adjust the ORDER BY.

Parameters
$fncSQL : string

SQL query for wzBuildDataBrowse

$fncTableId : mixed
Return values
string

$fncSQL sends back SQL query with adjusted ORDER BY

wzFillBrowsePage()

Fill Browse Page: this uses any SQL SELECT statement to build a full page showing the result set.

wzFillBrowsePage( string  $fncSQL , array<string|int, mixed>  $fncSqlFilter [, string  $fncTableId = 'wtkBr' ] [, string  $fncURL = '' ] [, string  $fncModalEdit = 'N' ] ) : string

The function is just a wrapper for wzBuildDataBrowse and includes a call to wzMergePage. Thus this function can be called when needing to display a single browse list in a single page (not to be used for Single-Page-Site navigation).

Parameters
$fncSQL : string

SQL Query that will retrieve list of data

$fncSqlFilter : array<string|int, mixed>

array that has PDO names of fields and their values

$fncTableId : string = 'wtkBr'

default value of 'wtkBr'

$fncURL : string = ''

when browse requires a different URL here for the AJAX to use for page navigation

$fncModalEdit : string = 'N'

is Y or N (default) showing whether should use popup modal window for edit

Tags
uses
function

wzMergePage

Return values
string

entire web page

wzBuildDataBrowse()

Build Data Browse in HTML table with sortable columns and option to show add, edit and delete button/features.

wzBuildDataBrowse( string  $fncSQL , array<string|int, mixed>  $fncSqlFilter [, string  $fncTableId = 'wtkBr' ][, string  $fncURL = '' ] [, string  $fncModalEdit = 'N' ] [, string  $fncDateFormat = '' ] ) : string

Pass in a SELECT statement and this returns an HTML table with an AJAX-driven result set. Use this instead of wzFillBrowsePage when multiple browses are needed on a page or you want to position a browse on a form page. The default 'wtkBr' will work as the TableID if there is only 1 browse on page. Each browse on a page must have a unique TableID in order for the AJAX data-set navigation to work.

Parameters
$fncSQL : string
$fncSqlFilter : array<string|int, mixed>

array that has PDO names of fields and their values

$fncTableId : string = 'wtkBr'

Default value ("wtkBr") will only work if 1 browse on page

$fncURL : string = ''
$fncModalEdit : string = 'N'

defaults to 'N' and edit links go to page as normal; if set to 'Y' then uses modalEdi

$fncDateFormat : string = ''

special feature to choose PHP date format for a Date column value

Tags
uses
function

wzSearchReplace

uses
function

wzTimeTrack

uses
function

wzConnectToDB

uses
function

wzRowFunction

Return values
string

entire browse list table

wzBuildFooter()

Build Footer

wzBuildFooter ( string  $fncTableId , string  $fncURL) : string

This builds the footer information that goes at the bottom of the browse result set and allows for page navigation. This is called from wzBuildDataBrowse and should not be called directly.

Parameters
$fncTableId : string
$fncURL : string
Tags
uses
function

wzTimeTrack

Return values
string

html footer for browse box navigation

wzSetHeaderSort()

Declare Columns to be sortable in browse list.

wzSetHeaderSort ( string  $fncColumn [, string  $fncColHeader = '' ] [, string  $fncColSort = '' ] ) : void

Before calling wzBuildDataBrowse use this function to declare which columns should be sortable. Pass in one, two or three parameters. The first parameter is the SQL column name. The second parameter is the alias or column header you wish to show; if this is ommitted then it will use the column name. If the value is not sortable, for example a formatted date, then for the third parameter pass the actual column name you want to sort on.

For example, for formatted dates pass in the third parameter of actual date field name and in the SELECT use an alias. For example call might be: wzSetHeaderSort("FormattedBDay", "Birthday", 'date_of_birth'); when your SELECT statement has something like: SELECT first_name, DATE_FORMAT(date_of_birth, '%M %d, %Y') FROM friend_list

Parameters
$fncColumn : string
$fncColHeader : string = ''
$fncColSort : string = ''
Tags
global

array $gloColHeaderArray holds passed parameters

uses
function

wzInsertSpaces to add spaces for column name

Return values
void

wzBuildColHeader()

Build Column Header

wzBuildColHeader( string  $fncColumn , string  $fncTableId , string  $fncURL) : string

This uses the values you passed in by calling wzSetHeaderSort to make columns sortable in the browse results. It is called by wzBuildDataBrowse and should not be called directly.

Parameters
$fncColumn : string

Column name to be shown in header of list. Will be sortable if previously declared by calling wzSetHeaderSort.

$fncTableId : string

by each browse list having different Table Ids sorts and page navigation know which browse to update

$fncURL : string

this determines what URL to call to update browse list

Return values
string

column header including sortable JavaScript function call to sort if necessary

wzBrowseExport()

This will export the results to CSV and show a download option instead of showing SQL as a browse result set.

wzBrowseExport( string  $fncSQL , array<string|int, mixed>  $fncSqlFilter , mixed  $fncTableId ) : html

If $fncTableId is 'modal' then returns HTML to display in a modal, otherwise uses wz/htm/mcbox.htm and returns entire page. Result has HTML tags removed and is saved to ../exports folder and this returns link to download the file. File is named based on $gloPageTitle (wtk if blank) . date('hms',time()) . '.csv'

Parameters
$fncSQL : string
$fncSqlFilter : array<string|int, mixed>

array that has PDO names of fields and their values

$fncTableId : mixed
Tags
global

string $gloWTKobjConn

global

string $gloPageTitle this is displayed to describe export

global

string $gloFormMsg this will be displayed below $gloPageTitle and above download link

global

string $gloTotalArray

global

string $glowRowChangeArray

uses
function

wzRemoveStyle to remove HTML styles from values

Return values
html

to allow downloading CSV file

wzBrowseExportXML()

This will export the results to XML and show a download option instead of showing SQL as a browse result set.

wzBrowseExportXML ( string  $fncSQL , array<string|int, mixed>  $fncSqlFilter , mixed  $fncTableId ) : html

If $fncTableId is 'modal' then returns HTML to display in a modal, otherwise uses wz/htm/mcbox.htm and returns entire page. Result has HTML tags removed and is saved to ../exports folder and this returns link to download the file. File is named based on $gloPageTitle (wtk if blank) . date('hms',time()) . '.xml'

Parameters
$fncSQL : string
$fncSqlFilter : array<string|int, mixed>

array that has PDO names of fields and their values

$fncTableId : mixed
Tags
global

string $gloWTKobjConn

global

string $gloPageTitle this is displayed to describe export

global

string $gloFormMsg this will be displayed below $gloPageTitle and above download link

global

string $gloTotalArray

global

string $glowRowChangeArray

uses
function

wzRemoveStyle to remove HTML styles from values

Return values
html

to allow downloading XML file

Search results