Skip to content

Instantly share code, notes, and snippets.

@pavelkucera
Created August 30, 2010 20:48
Show Gist options
  • Save pavelkucera/558027 to your computer and use it in GitHub Desktop.
Save pavelkucera/558027 to your computer and use it in GitHub Desktop.
// Create a query
$df = new \DibiFluent(\dibi::getConnection());
$df->select('p.*')
->select('c.name')->as('city')
->from('%n', 'people', 'p')
->leftJoin('%n', 'cities', 'c')
->on('(p.[city_id] = c.[id])');
// Configure data source
$dataSource = new \DataGrid\DataSources\Dibi\Fluent($df);
$dataSource->setMapping(array(
'id' => 'p.ID',
'name' => 'p.name',
'mail' => 'p.mail',
'city' => 'c.name',
'registered' => 'p.registered',
));
// Configure data grid
$grid = new \DataGrid\DataGrid;
$grid->setDataSource($dataSource);
// Configure columns
$grid->addNumericColumn('id', 'ID')->addFilter();
$grid->addColumn('name', 'Jméno')->addFilter();
$grid->addColumn('mail', 'E-mail')->addFilter();
$grid->addColumn('city', 'Město')->addFilter();
$grid->addDateColumn('date', 'Registrován')->addFilter();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment