Jeff PHP framework  0.99
Modular, extensible, OOP, MVC, lightweight php framework designed to ease the programmers in the development of web applications.
export Class Reference

Data exportation class. More...

Public Member Functions

 __construct ($opts=array())
 Construct an export instance.
 exportData ($filename, $extension, $output='stream')
 Data exportation.
 setData ($data)
 Sets the $_data property.
 setFieldEnclosure ($fe)
 Sets the $_fe property.
 setFields ($fields)
 Sets the $_fields property.
 setFkeys ($fkeys)
 Set the $_fkeys property.
 setHead ($head)
 Sets the $_head property.
 setOrder ($order)
 Sets the $_order property.
 setRids ($rids)
 Sets the $_rids property.
 setSeparator ($s)
 Sets the $_s property.
 setSfields ($sfields)
 Sets the $_sfields property.
 setTable ($table)
 Sets the $_table property.

Private Member Functions

 encloseField ($field)
 Encloses a string between the enclosire characters.
 exportCsv ($filename, $output)
 Data exportation in csv format.
 getData ()
 Returns data inside an array.
 getHeadFields ($table_structure)
 Get column names of the given fields from a database table.

Private Attributes

 $_data
 array of data to export
 $_fe
 field enclosure character
 $_fields
 the fields to export
 $_fkeys
 foreign keys
 $_head
 whether or not to print fields' headings
 $_order
 the field used to sort the results
 $_pkey
 table primary key field
 $_registry
 the registry singleton instance
 $_rids
 the records ids to export
 $_s
 data separator character
 $_sfields
 special fields
 $_table
 database table

Detailed Description

Data exportation class.

This classed is used to export database tables or arrays of data to csv files.

Author:
abidibo abidi.nosp@m.bo@g.nosp@m.mail..nosp@m.com
Version:
0.99
Date:
2011-2012

Definition at line 23 of file export.class.php.


Constructor & Destructor Documentation

export::__construct ( opts = array())

Construct an export instance.

Parameters:
array$optsAssociative array of options:
  • separator: string default ','. Data separator character
  • field_enclosure: string default '"'. Field enclosure character
  • table: string. Database table
  • pkey: string default 'id'. Table primary key field
  • sfields: array default array(). Special fields, same as adminTable
  • fkeys: array default array(). Foreign keys, same as adminTable
  • head: bool default true. Whether or not to print fields' headings
  • fields: mixed default '*'. Fields to export. Possible values are:
    • *****: all fields
    • **-(field1, field2)**: all fields except from field1 and field2
    • field1,field2: the fields field1 and field2
    • array('field1', 'field2'): the fields field1 and field2
  • rids: mixed default '*'. Records to export. Possible values are:
    • *****: all records
    • **-(field1, field2)**: all fields except from field1 and field2
    • 1,3,5: the records with id=1, id=3 and id=5
    • array(1,3,5): the records with id=1, id=3 and id=5
  • order: string default ''. The field used to sort the results
  • data: array default array(). Arra of data to export. Competitive to table option, ie: array( 0=>array("head1", "head2", "head3"), 1=>array("value1 record 1", "value 2 record 1", "value 3 record 1"), 2=>array("value1 record 2", "value 2 record 2", "value 3 record 2") )
Returns:
export instance

Definition at line 116 of file export.class.php.

+ Here is the call graph for this function:


Member Function Documentation

export::encloseField ( field) [private]

Encloses a string between the enclosire characters.

Parameters:
mixed$fieldfield to enclose
Returns:
void

Definition at line 361 of file export.class.php.

+ Here is the caller graph for this function:

export::exportCsv ( filename,
output 
) [private]

Data exportation in csv format.

Parameters:
string$filenamename of the exportation file
mixed$outputoutput type. Possible values are:
  • stream: the data are streamed directly to the browser
  • file: the data are saved to file
Returns:
void

Definition at line 259 of file export.class.php.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

export::exportData ( filename,
extension,
output = 'stream' 
)

Data exportation.

Parameters:
string$filenamename of the exportation file
string$extensionextension of the exportation file
string$outputoutput type. Possible values are:
  • stream: the data are streamed directly to the browser
  • file: the data are saved to file
Returns:
void

Definition at line 244 of file export.class.php.

+ Here is the call graph for this function:

export::getData ( ) [private]

Returns data inside an array.

If data are already given in an array form returns them, if data are stored in a database table reads them and puts them in an aray structure.

private

Returns:
void

Definition at line 297 of file export.class.php.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

export::getHeadFields ( table_structure) [private]

Get column names of the given fields from a database table.

Parameters:
array$table_structuredatabase table structure as returned by mysql::getTableStructure
Returns:
void

Definition at line 338 of file export.class.php.

+ Here is the caller graph for this function:

export::setData ( data)

Sets the $_data property.

Parameters:
array$datadata value (see export)
Returns:
void

Definition at line 230 of file export.class.php.

Sets the $_fe property.

Parameters:
string$fefield enclosure character
Returns:
void

Definition at line 180 of file export.class.php.

export::setFields ( fields)

Sets the $_fields property.

Parameters:
mixed$fieldsfields value (see export)
Returns:
void

Definition at line 190 of file export.class.php.

export::setFkeys ( fkeys)

Set the $_fkeys property.

Parameters:
array$fkeysforeign keys
Returns:
void

Definition at line 160 of file export.class.php.

export::setHead ( head)

Sets the $_head property.

Parameters:
bool$headheadings visibility (see export)
Returns:
void

Definition at line 200 of file export.class.php.

export::setOrder ( order)

Sets the $_order property.

Parameters:
string$ordersort order (see export)
Returns:
void

Definition at line 220 of file export.class.php.

export::setRids ( rids)

Sets the $_rids property.

Parameters:
mixed$ridsrids value (see export)
Returns:
void

Definition at line 210 of file export.class.php.

Sets the $_s property.

Parameters:
string$sseparator character
Returns:
void

Definition at line 170 of file export.class.php.

export::setSfields ( sfields)

Sets the $_sfields property.

Parameters:
array$sfieldsspecial fields
Returns:
void

Definition at line 150 of file export.class.php.

export::setTable ( table)

Sets the $_table property.

Parameters:
string$tabledatabse table
Returns:
void

Definition at line 140 of file export.class.php.


Field Documentation

export::$_data [private]

array of data to export

Definition at line 83 of file export.class.php.

export::$_fe [private]

field enclosure character

Definition at line 38 of file export.class.php.

export::$_fields [private]

the fields to export

Definition at line 68 of file export.class.php.

export::$_fkeys [private]

foreign keys

Definition at line 58 of file export.class.php.

export::$_head [private]

whether or not to print fields' headings

Definition at line 63 of file export.class.php.

export::$_order [private]

the field used to sort the results

Definition at line 78 of file export.class.php.

export::$_pkey [private]

table primary key field

Definition at line 48 of file export.class.php.

export::$_registry [private]

the registry singleton instance

Definition at line 28 of file export.class.php.

export::$_rids [private]

the records ids to export

Definition at line 73 of file export.class.php.

export::$_s [private]

data separator character

Definition at line 33 of file export.class.php.

export::$_sfields [private]

special fields

Definition at line 53 of file export.class.php.

export::$_table [private]

database table

Definition at line 43 of file export.class.php.


The documentation for this class was generated from the following file: