在Diem中,我想做一个条件语句,它将排除一些基于标记模型的文章。
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标签插件。我没有修改模型,也没有修改表的名称。
发布于 2011-05-31 15:07:56
这是一个工作查询:
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);
}https://stackoverflow.com/questions/6177336
复制相似问题