PEAR Manual
Prev |  | Next

# Structures_DataGrid_DataSource::create()

Structures_DataGrid_DataSource::create() -- Creates a Structures_DataGrid_DataSource object

## Synopsis

``string Structures_DataGrid_DataSource::create` (object $source, array $options, string $type)`

## Description

This method will create the datasource driver object by attempting to detect it's type. If the type can be found the driver will be instantiated and returned, if it cannot be detected, an error will be returned. When using bundled data drivers, the bind() method is the preferred approach, this method exists for those who wish to create their own data source driver. If you do create your own driver and find that it may be useful to others, please post it to the mailing list so that it could be bundled into the package.

## Parameter

mixed `$source`

  The original data source.

array `$options`

  An array of options to be used, these are respective to the driver.

string `$type`

  Optional. This is used if the data source type cannot be detected.

## Return value

object - The Structures_DataGrid_DataSource object

## Note

This function can be called statically.

## Example

Example 55-1. Creating a datasource object.
    <?php
    require_once 'Structures/DataGrid.php';
    require_once 'myDataObjects/User.php';

    $user = new User();

    $dg =& new Structures_DataGrid();
    $ds = Structures_DataGrid_DataSource::create($user);
    $dg->bindDataSource($ds);

    $dg->render();
    ?>

Prev | Home | Next
Structures_DataGrid_DataSource | Up | Structures_Graph