Write tables from arrays or datasets.

Helps building tables by either loading data in one bite via passing an array or CSV file, or by adding the data one row at a time.

package dstruct_presentation

 Methods

Class Constructor <var>$dataset</var> can be used to 'bulk add' data to the table.

__construct(string $class, mixed $dataset, boolean $iscsv) 

Parameters

$class

string

The CSS class to be written to the table

$dataset

mixed

Either array or db resultset or CSV string

$iscsv

boolean

Data being added is a CSV string.

Add CSV data to the table.

addCSV(string $data) 

Parameters

$data

string

Add <th> elements to the table.

addHeaders($headers) 

Parameters

$headers

array Header titles from left to right

Add a row to the table.

addRow($arraydata) 

The array will be added to the end of the current data, with the fields added as cells from left to right.
There is currently no checking that the array has the correct number of items.

Parameters

$arraydata

array

Clear the object.

clear(boolean $clearsettings) 

Removes all data, counters and header info.

Parameters

$clearsettings

boolean

Clear all CSV settings too.

Set the character CSV fields are enclosed by.

setEnclosedBy(string $enc) 

Default is double quote. Set an empty string if the CSV fields are not enclose.

Parameters

$enc

string

HTML encode the output.

setEncodeOutput(boolean $enc) 

Encodes headers and data. Default is FALSE.

Parameters

$enc

boolean

Get the completed table.

write($tablestart, $tableend) : string

The $tablestart and $tableend params can be used to suppress the

and

elements.
This can be useful in a number of cases, such as buffering the output of very long tables.

Parameters

$tablestart

boolean Include

<

table> in output

$tableend

boolean Include in output

Returns

string

 Properties

 

$arraydata : array
 

$class : string
 

$csvenclosedby : string
 

$csvescape : string
 

$csvhasheader : boolean
 

$csvline : string
 

$csvseparator : string
 

$dbobjectdata : array
todo check datatype
 

$encodeoutput : boolean
 

$headers : array
 

$iscsv : boolean
 

$z : integer