## Apache Zeta Components Manual :: Docs For Class ezcGraphDatabaseDataSet

### GraphDatabaseTiein::ezcGraphDatabaseDataSet

### Class ezcGraphDatabaseDataSet

Class to transform PDO results into ezcGraphDataSets

Source for this file: /GraphDatabaseTiein/src/dataset.php

    ezcGraphDataSet
       |
       --ezcGraphDatabaseDataSet

Version: | //autogentag//

### Inherited Member Variables

From ezcGraphDataSet
protected | `ezcGraphDataSet::$current`
protected | `ezcGraphDataSet::$data`
protected | `ezcGraphDataSet::$keys`
protected | `ezcGraphDataSet::$pallet`
protected | `ezcGraphDataSet::$properties`

### Method Summary

public ezcGraphDatabase | `__construct( $statement , [ $definition = null] )` Constructor
public int | `count( )` Returns the number of elements in this dataset
protected void | `createFromPdo( $statement , [ $definition = null] )` Create dataset from PDO statement
protected void | `fetchByDefinition( $statement , $definition )` Fecth data by provided definition
protected void | `fetchNumeric( $statement )` Fetch numeric

### Inherited Methods

From ezcGraphDataSet
public string | `ezcGraphDataSet::current()` Returns the currently selected datapoint.
public string | `ezcGraphDataSet::key()` Returns the key of the currently selected datapoint.
public float | `ezcGraphDataSet::next()` Returns the next datapoint and selects it or false on the last datapoint.
public bool | `ezcGraphDataSet::offsetExists()` Returns true if the given datapoint exists Allows isset() using ArrayAccess.
public float | `ezcGraphDataSet::offsetGet()` Returns the value for the given datapoint Get an datapoint value by ArrayAccess.
public void | `ezcGraphDataSet::offsetSet()` Sets the value for a datapoint.
public void | `ezcGraphDataSet::offsetUnset()` Unset an option.
public float | `ezcGraphDataSet::rewind()` Selects the very first datapoint and returns it.
public bool | `ezcGraphDataSet::valid()` Returns if the current datapoint is valid.
public mixed | `ezcGraphDataSet::__get()` Property get access.

### Methods

#### __construct

ezcGraphDatabase __construct( $statement , [ $definition = null] )

Constructor

Creates a ezcGraphDatabase from a PDOStatement and uses the columns defined in the definition array as keys and values for the data set.

If the definition array is empty a single column will be used as values, with two columns the first column will be used for the keys and the second for the data set values.

You may define the name of the rows used for keys and values by using an array like: array ( ezcGraph::KEY => 'row name', ezcGraph::VALUE => 'row name', );

PDO by default lowercases all column names, see PDO::setAttribute() for details. If the column names you pass to the dataset definition array are not lowercase, you either need to change the PDO::ATTR_CASE attribute of your PDO connection instance, or lowercase the names passed to the definition array. Otherwise this will throw ezcGraphDatabaseMissingColumnException exceptions.

##### Parameters:

Name | Type | Description
--- | --- | ---
`$statement` | PDOStatement |
`$definition` | array |

#### count

int count( )

Returns the number of elements in this dataset

#### createFromPdo

void createFromPdo( $statement , [ $definition = null] )

Create dataset from PDO statement

This methods uses the values from a PDOStatement to fill up the data sets data.

If the definition array is empty a single column will be used as values, with two columns the first column will be used for the keys and the second for the data set values.

You may define the name of the rows used for keys and values by using an array like: array ( ezcGraph::KEY => 'row name', ezcGraph::VALUE => 'row name', );

##### Parameters:

Name | Type | Description
--- | --- | ---
`$statement` | PDOStatement |
`$definition` | array |

#### fetchByDefinition

void fetchByDefinition( $statement , $definition )

Fecth data by provided definition

Use the provided definition with column names to fetch specific columns as key and values. Will throw a ezcGraphDatabaseMissingColumnException, if the column does not exist in the query result.

##### Parameters:

Name | Type | Description
--- | --- | ---
`$statement` | PDOStatement |
`$definition` | array |

#### fetchNumeric

void fetchNumeric( $statement )

Fetch numeric

If there is only one column returned by the query use the column as values for the dataset. If there are two columns returned use the first as key and the second as values for teh dataset.

If there are more or less columns returned, a ezcGraphDatabaseTooManyColumnsException is thrown.

##### Parameters:

Name | Type | Description
--- | --- | ---
`$statement` | PDOStatement |

Documentation generated by phpDocumentor 1.4.3