本文整理汇总了PHP中CDbCriteria::wergeWith方法的典型用法代码示例。如果您正苦于以下问题:PHP CDbCriteria::wergeWith方法的具体用法?PHP CDbCriteria::wergeWith怎么用?PHP CDbCriteria::wergeWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDbCriteria
的用法示例。
在下文中一共展示了CDbCriteria::wergeWith方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAllTagsWithModelsCount
/**
* Get all possible tags with models count for each for this model class.
*
* @param CDbCriteria $criteria
* @return array
*/
public function getAllTagsWithModelsCount($criteria = null)
{
if (!($tags = $this->cache->get('Taggable' . $this->getOwner()->tableName() . 'AllWithCount'))) {
// getting associated tags
$builder = $this->getOwner()->getCommandBuilder();
$tagsCriteria = new CDbCriteria();
if ($this->tagTableCount !== null) {
$tagsCriteria->select = sprintf("t.%s as `name`, %s as `count`", $this->tagTableName, $this->tagTableCount);
} else {
$tagsCriteria->select = sprintf("t.%s as `name`, count(*) as `count`", $this->tagTableName);
$tagsCriteria->join = sprintf("JOIN `%s` et ON t.{$this->tagTablePk} = et.%s", $this->getTagBindingTableName(), $this->tagBindingTableTagId);
$tagsCriteria->group = 't.' . $this->tagTablePk;
}
if ($criteria !== null) {
$tagsCriteria->mergeWith($criteria);
}
if ($this->getScopeCriteria()) {
$tagsCriteria->wergeWith($this->getScopeCriteria());
}
$tags = $builder->createFindCommand($this->tagTable, $tagsCriteria)->queryAll();
$this->cache->set('Taggable' . $this->getOwner()->tableName() . 'AllWithCount', $tags);
}
return $tags;
}