Created
August 30, 2010 20:48
-
-
Save pavelkucera/558027 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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