I’m trying to use a parameter in my CDbCacheDependency cache settings but I’m getting the following error:
SQLSTATE[HY093]: Invalid parameter number: Columns/Parameters are 1-based
Here are my cache settings in my controller:
public function filters()
{
return array(
'accessControl', // perform access control for CRUD operations
'postOnly + delete', // we only allow deletion via POST request
array(
'COutputCache + index',
'requestTypes' => array('GET'),
'duration'=> 60 * 60 * 24,
'varyByParam' => array('Post_page'),
'dependency'=>array(
'class'=>'system.caching.dependencies.CDbCacheDependency',
'sql'=>'SELECT MAX(modified) FROM post',
),
),
array(
'COutputCache + view',
'requestTypes' => array('GET'),
'duration'=> 60 * 60 * 24,
'varyByParam' => array('slug'),
'dependency'=>array(
'class'=>'system.caching.dependencies.CDbCacheDependency',
'sql'=> 'SELECT MAX(modified) FROM post WHERE slug = :slug',
'params' => array(':slug', $_GET['slug']),
),
),
);
}
The index cache works correctly, however when I added the view cache I get the above error. If I manually specify the slug value (e.g. 'SELECT MAX(modified) FROM post WHERE slug = ‘xyz’) then it works but I’m having trouble parameterizing it.