PEAR Manual
Prev |  | Next

# Structures_DataGrid::bindDataSource()

Structures_DataGrid::bindDataSource() -- Binds a Structures_DataGrid_DataSource object to the DataGrid.

## Synopsis

``object bindDataSource` (Structures_DataGrid_DataSource $source)`

## Description

Binds a Structures_DataGrid_DataSource object to the DataGrid.

## Parameter

Structures_DataGrid_DataSource `$source`

  The DataSource object

## Return value

mixed - `TRUE` upon success otherwise a PEAR_Error upon failure

## Example

Example 55-1. Bind datagrid to a DB_Result Object
    <?php
    require 'Structures/DataGrid.php';
    require 'Structures/DataGrid/DataSource.php';

    $dg =& new Structures_DataGrid();

    // Get my data
    $result = $db->query('SELECT * FROM users');

    // Bind to DataGrid
    $data = Structures_DataGrid_DataSource::create($result);
    $dg->bindDataSource($data);

    // Print the DataGrid
    $dg->render();
    ?>

Prev | Home | Next
Structures_DataGrid::bind() | Up | Structures_DataGrid::render()