我的问题很愚蠢,但我找不到该学说2 dbal和缓存管理器的示例。
我无法在dbal查询上使用usereSultCache方法?
$q = Zend_Registry::get('em')->getConnection()->createQueryBuilder()
->select('f.idprd, f.lprd')
->from('tb_prd', 'f')
->andWhere($q->expr()->eq('f.niveau', $iNiveau))
->orderBy('f.niveau')
非常感谢!
我发现:
https://github.com/doctrine/dbal-documentation/blob/master/en/reference/caching.rst
它正在工作:
public static function getList() {
$q = Zend_Registry::get('em')->getConnection()->createQueryBuilder()
->select("np.*")
->from('tb_niv_prd', 'np')
->andWhere("np.lniveau IS NOT NULL")
->andWhere("np.niveau <> 10")
->addOrderBy('np.lniveau', 'ASC');
$stmt = Zend_Registry::get('em')->getConnection()->executeCacheQuery(
$q->getSql(), array(), array(), new DoctrineDBALCacheQueryCacheProfile(0,
"TbNivPrdRepository_getList"));
$aResult = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
return $aResult;
}