Skip to content

Instantly share code, notes, and snippets.

<?php
namespace DataGrid\DataSources\Dibi;
use Nette, Doctrine, DataGrid,
DataGrid\DataSources\IDataSource,
DataGrid\DataSources,
dibi, DibiDataSource;
/**
* Dibi data source based data source
<?php
namespace DataGrid\DataSources\Dibi;
use DataGrid\DataSources\IDataSource,
DataGrid\DataSources,
dibi,
DibiFluent;
/**
* Dibi fluent based data source
// 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);
// Create a query
$ds = \dibi::dataSource('SELECT p.*, c.[name] as city FROM [people] p LEFT JOIN [cities] c ON p.[city_id] = c.[id]');
// Create a data source
$dataSource = new \DataGrid\DataSources\Dibi\DataSource($ds);
// Configure data grid
$grid = new DataGrid;
$grid->setDataSource($dataSource);
<?php
/**
* This file is part of the Nette Framework (http://nette.org)
*
* Copyright (c) 2004, 2011 David Grudl (http://davidgrudl.com)
*
* For the full copyright and license information, please view
* the file license.txt that was distributed with this source code.
*/
@pavelkucera
pavelkucera / gist:969030
Created May 12, 2011 17:37
Doctrine bug?
<?php
$entity = $repository->find($id);
$entity->getAssociation()->setProperty('new value');
echo $entity->getAssocation()->getProperty(); // prints 'new value'
$em->persist($entity->getAssociation()); // pratically a useless row, the association entity should be already persisted
$em->flush();
$em->refresh($entity->getAssociation());
echo $entity->getAssocation()->getProperty(); // prints the old value
/**
* @entity(serviceClass="EntityService") // tohle jsem chtěl zprovoznit, ale vyžadovalo by to úpravu Doctrine
* @service(class="EntityService") // takže jsem se spokojil s tímhle
*/
class Entity
{
}
<?php
$userService = new User\UserService($em, $cacheStorage);
$container->addService('userService', $userService);
$container->userService->getRepository()->findAllWithStar();
/**
* Beta
*
* Sibling of netteForms.js "rewritten to jQuery"
* @author Pavel Kučera
* @author David Grudl author of netteForms.js, of the idea and the one who I copied from
*
* Disclaimer: I'm not a javascript programmer, actually I hate javascript, so consider that please if you want to complain about quality of this utility.
*
* Dependencies
@pavelkucera
pavelkucera / gist:1302248
Created October 20, 2011 20:23
Trable s kódem
Nette mi pravděpodobně kvůli Nelle vyhazuje fatal error v kešovaném konfigu, k odstranění stačí:
1) přidat na začátek kešovaného souboru die('G');
2) soubor spustit, ať zemře na lajně přidané v kroku 1)
3) zakomentovat řádek se smrtí
Po této proceduře se fatal error přestane objevovat! Žádný racionální důvod proč to tak je mě fakt nenapadá :/.