Structures_DataGrid
[ class tree: Structures_DataGrid ] [ index: Structures_DataGrid ] [ all elements ]

Class: Structures_DataGrid_DataSource

Source Location: /Structures_DataGrid-0.9.3/Structures/DataGrid/DataSource.php

Class Overview


Base abstract class for DataSource drivers


Author(s):

Version:

  • $Revision$

Variables

Methods


Child classes:

Structures_DataGrid_DataSource_SQLQuery
Base abstract class for SQL query based DataSource drivers

Inherited Variables

Inherited Methods


Class Details

[line 76]
Base abstract class for DataSource drivers

SUPPORTED OPTIONS:

  • fields: (array) Which data fields to fetch from the datasource. An empty array means: all fields. Form: array(field1, field2, ...)
  • primaryKey: (array) Name(s), or numerical index(es) of the field(s) which contain a unique record identifier (only use several fields in case of a multiple-fields primary key)
  • generate_columns: (bool) Generate Structures_DataGrid_Column objects with labels. See the 'labels' option. DEPRECATED: use Structures_DataGrid::generateColumns() instead
  • labels: (array) Data field to column label mapping. Only used when 'generate_columns' is true. Form: array(field => label, ...) DEPRECATED: use Structures_DataGrid::generateColumns() instead



[ Top ]


Class Variables

$_features = array()

[line 94]

Special driver features
  • Access: protected

Type:   array


[ Top ]

$_options = array()

[line 86]

Common and driver-specific options
  • See: Structures_DataGrid_DataSource::addDefaultOptions()
  • See: Structures_DataGrid_DataSource::_setOption()
  • Access: protected

Type:   array


[ Top ]



Method Detail

Structures_DataGrid_DataSource (Constructor)   [line 100]

Structures_DataGrid_DataSource Structures_DataGrid_DataSource( )

Constructor

[ Top ]

bind   [line 287]

object PEAR_Error bind( mixed $container, [array $options = array()])

Datasource binding method prototype

This method is public, but please note that it is not intended to be called by user-space code. It is meant to be called by the main Structures_DataGrid class.

It is an abstract method, part of the DataGrid Datasource driver interface, and must/may be overloaded by drivers. When overloaded this method must return true on success or a PEAR_Error object on failure.

  • Return: with message "No data source driver loaded"
  • Abstract:
  • Access: public

Overridden in child classes as:

Structures_DataGrid_DataSource_SQLQuery::bind()
Bind

Parameters:

mixed   $container   —  The datasource container
array   $options   —  Binding options

[ Top ]

count   [line 244]

object PEAR_Error count( )

Counting method prototype

This method is public, but please note that it is not intended to be called by user-space code. It is meant to be called by the main Structures_DataGrid class.

It is an abstract method, part of the DataGrid Datasource driver interface, and must/may be overloaded by drivers. Note: must be called before fetch()

When overloaded, this method must return the total number or records or a PEAR_Error object on failure

  • Return: with message "No data source driver loaded"
  • Abstract:
  • Access: public

Overridden in child classes as:

Structures_DataGrid_DataSource_SQLQuery::count()
Count

[ Top ]

delete   [line 371]

object PEAR_Error delete( array $key)

Record deletion method prototype

This method is public, but please note that it is not intended to be called by user-space code. It is meant to be called by the main Structures_DataGrid class.

It is an abstract method, part of the DataGrid Datasource driver interface, and must/may be overloaded by drivers. Drivers that support the "writeMode" feature must implement this method.

When overloaded this method must return true on success or a PEAR_Error object on failure.

  • Return: with message "No data source driver loaded or write mode not supported by the current driver"
  • Abstract:
  • Access: public

Parameters:

array   $key   —  Unique record identifier

[ Top ]

dump   [line 433]

string dump( [integer $offset = 0], [integer $len = null], [string $sortField = null], [string $sortDir = 'ASC'])

Dump the data as returned by fetch().

This method is meant for debugging purposes. It returns what fetch() would return to its DataGrid host as a nicely formatted console-style table.


Parameters:

integer   $offset   —  Limit offset (starting from 0)
integer   $len   —  Limit length
string   $sortField   —  Field to sort by
string   $sortDir   —  Sort direction: 'ASC' or 'DESC'

[ Top ]

fetch   [line 226]

object PEAR_Error fetch( [integer $offset = 0], [integer $len = null])

Fetching method prototype

This method is public, but please note that it is not intended to be called by user-space code. It is meant to be called by the main Structures_DataGrid class.

It is an abstract method, part of the DataGrid Datasource driver interface, and must/may be overloaded by drivers. When overloaded this method must return an array of records. Each record can be either an associative array of field name/value pairs, or an object carrying fields as properties.

This method must return a PEAR_Error object on failure.


Overridden in child classes as:

Structures_DataGrid_DataSource_SQLQuery::fetch()
Fetch

Parameters:

integer   $offset   —  Limit offset (starting from 0)
integer   $len   —  Limit length

[ Top ]

free   [line 387]

void free( )

Resources cleanup method prototype

This method is public, but please note that it is not intended to be called by user-space code. It is meant to be called by the main Structures_DataGrid class.

It is an abstract method, part of the DataGrid Datasource driver interface, and must/may be overloaded by drivers. This is where drivers should close sql connections, files, etc... if needed.

  • Abstract:
  • Access: public

Overridden in child classes as:

Structures_DataGrid_DataSource_SQLQuery::free()
Disconnect from the database, if needed

[ Top ]

getColumns   [line 180]

array getColumns( )

Generate columns if options are properly set

Note: must be called after fetch()

  • Return: Array of Column objects. Empty array if irrelevant.
  • Deprecated: This method relates to the deprecated "generate_columns" option.
  • Access: public

[ Top ]

getFeatures   [line 401]

array getFeatures( )

List special driver features
  • Return: Of the form: array(feature => true|false, etc...)
  • Access: public

[ Top ]

getPrimaryKey   [line 328]

array getPrimaryKey( )

Return the primary key specification

This method is public, but please note that it is not intended to be called by user-space code. It is meant to be called by the main Structures_DataGrid class.

It is an abstract method, part of the DataGrid Datasource driver interface, and must/may be overloaded by drivers. This method always returns an array containing:

  • either one field name or index in case of a single-field key
  • or several field names or indexes in case of a multiple-fields key
Drivers that support the "writeMode" feature should overload this method if the key can be detected. However, the detection must not override the "primaryKey" option.

  • Return: Field(s) name(s) or numerical index(es)
  • Access: protected

[ Top ]

hasFeature   [line 413]

bool hasFeature( string $name)

Tell if the driver as a specific feature
  • Access: public

Parameters:

string   $name   —  Feature name

[ Top ]

insert   [line 308]

object PEAR_Error insert( array $data)

Record insertion method prototype

This method is public, but please note that it is not intended to be called by user-space code. It is meant to be called by the main Structures_DataGrid class.

It is an abstract method, part of the DataGrid Datasource driver interface, and must/may be overloaded by drivers. Drivers that support the "writeMode" feature must implement this method.

When overloaded this method must return true on success or a PEAR_Error object on failure.

  • Return: with message "No data source driver loaded or write mode not supported by the current driver"
  • Abstract:
  • Access: public

Parameters:

array   $data   —  Associative array of the form: array(field => value, ..)

[ Top ]

setOption   [line 166]

void setOption( string $name, mixed $value)

Set a single option
  • Access: public

Parameters:

string   $name   —  Option name
mixed   $value   —  Option value

[ Top ]

setOptions   [line 154]

void setOptions( mixed $options)

Set options
  • Access: protected

Parameters:

mixed   $options   —  An associative array of the form: array("option_name" => "option_value",...)

[ Top ]

sort   [line 269]

object PEAR_Error sort( string $sortSpec, [string $sortDir = null])

Sorting method prototype

This method is public, but please note that it is not intended to be called by user-space code. It is meant to be called by the main Structures_DataGrid class.

It is an abstract method, part of the DataGrid Datasource driver interface, and must/may be overloaded by drivers. When overloaded this method must return true on success or a PEAR_Error object on failure.

Note: must be called before fetch()

  • Return: with message "No data source driver loaded"
  • Abstract:
  • Access: public

Overridden in child classes as:

Structures_DataGrid_DataSource_SQLQuery::sort()
This can only be called prior to the fetch method.

Parameters:

string   $sortSpec   —  If the driver supports the "multiSort" feature this can be either a single field (string), or a sort specification array of the form: array(field => direction, ...) If "multiSort" is not supported, then this can only be a string.
string   $sortDir   —  Sort direction: 'ASC' or 'DESC'

[ Top ]

update   [line 350]

object PEAR_Error update( array $key, array $data)

Record updating method prototype

This method is public, but please note that it is not intended to be called by user-space code. It is meant to be called by the main Structures_DataGrid class.

It is an abstract method, part of the DataGrid Datasource driver interface, and must/may be overloaded by drivers. Drivers that support the "writeMode" feature must implement this method.

When overloaded this method must return true on success or a PEAR_Error object on failure.

  • Return: with message "No data source driver loaded or write mode not supported by the current driver"
  • Abstract:
  • Access: public

Parameters:

array   $key   —  Unique record identifier
array   $data   —  Associative array of the form: array(field => value, ..)

[ Top ]

_addDefaultOptions   [line 126]

void _addDefaultOptions( array $options)

Adds some default options.

This method is meant to be called by drivers. It allows adding some default options.

  • See: Structures_DataGrid_DataSource::_setOption
  • Access: protected

Parameters:

array   $options   —  An associative array of the form: array(optionName => optionValue, ...)

[ Top ]

_setFeatures   [line 142]

void _setFeatures( array $features)

Add special driver features

This method is meant to be called by drivers. It allows specifying the special features that are supported by the current driver.

  • Access: protected

Parameters:

array   $features   —  An associative array of the form: array(feature => true|false, ...)

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:47:20 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.