问题描述
|
在DIEM CMF中,我想做一个条件语句,该语句将排除基于标记模型的某些文章
Diem文档为条件查询提供了以下内容(http://diem-project.org/diem-5-1/doc/en/reference-book/list-widgets)
$query = $this->getListQuery(\'post\')
->addWhere(\'post.name LIKE ?\',\'%symfony%\');
有没有一种方法可以根据其标签排除某些帖子?
谢谢
更新资料
这是我的新查询(至少对我而言)似乎更好,但仍然无法正常工作。
public function executeList()
{
$query = $this->getListQuery();
$query->leftJoin(\'DmTag\');
$query->addWhere(\'DmTag.name NOT LIKE ?\',\'%Fichets%\');
$this->articlePager = $this->getPager($query);
$this->articlePager->setoption(\'ajax\',true);
}
Diem博客是根据Diem教程完成的,我使用标准的Diem Tag插件(可以说是开箱即用的)。我没有修改模型或表的名称。
解决方法
这是工作查询:
public function executeList()
{
$query = $this->getListQuery(\'a\'); // add an alias
$query->leftJoin(\'a.Tags t\'); // Join on the DmTag table
$query->addWhere(\'t.name NOT LIKE ?\',\'%Fichets%\'); //Exclude the articles with a certain tag
$this->articlePager = $this->getPager($query);
$this->articlePager->setOption(\'ajax\',true);
}