本文整理汇总了PHP中ContentModel::countBy方法的典型用法代码示例。如果您正苦于以下问题:PHP ContentModel::countBy方法的具体用法?PHP ContentModel::countBy怎么用?PHP ContentModel::countBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContentModel
的用法示例。
在下文中一共展示了ContentModel::countBy方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: countExistingTabSeparators
/**
* Count existing tab separators elements.
*
* @param \Database\Result $model Current row.
* @param Helper $helper Wrapper helper.
*
* @return int
*/
public function countExistingTabSeparators(\Database\Result $model, Helper $helper)
{
if ($helper->isTypeOf(Helper::TYPE_START)) {
$modelId = $model->id;
} else {
$modelId = $model->bootstrap_parentId;
}
$number = \ContentModel::countBy('type=? AND bootstrap_parentId', array($helper->getTypeName(Helper::TYPE_SEPARATOR), $modelId));
return $number;
}
示例2: countRelatedElements
/**
* count related elements optionally limited by type
*
* @param Model $model
* @param string $type
* @return int
*/
public static function countRelatedElements(Model $model, $type = null)
{
if ($model->getType() == $model::TYPE_START) {
if ($type === null) {
$column = 'bootstrap_parentId';
$values = $model->id;
} else {
$column = array('bootstrap_parentId=?', 'type=?');
$values = array($model->id, $model->getTypeName($type));
}
} elseif ($type === null) {
$column = array('id !=?', '(bootstrap_parentId=? OR id=?)');
$values = array($model->id, $model->bootstrap_parentId, $model->bootstrap_parentId);
} elseif ($type == $model::TYPE_START) {
$column = 'id';
$values = $model->bootstrap_parentId;
} else {
$column = array('id !=?', 'bootstrap_parentId=?', 'type=?');
$values = array($model->id, $model->bootstrap_parentId, $model->getTypeName($type));
}
return \ContentModel::countBy($column, $values);
}
示例3: countRelatedElements
/**
* Count related elements.
*
* @param string|null $type Name of the type. If empty current type is used.
*
* @return int
*/
public function countRelatedElements($type = null)
{
$model = $this->model;
if ($this->isTypeOf(static::TYPE_START)) {
if ($type === null) {
$column = array('bootstrap_parentId=?');
$values = array($model->id);
} else {
$column = array('bootstrap_parentId=?', 'type=?');
$values = array($model->id, $this->getTypeName($type));
}
} elseif ($type === null) {
$column = array('id !=?', '(bootstrap_parentId=? OR id=?)');
$values = array($model->id, $model->bootstrap_parentId, $model->bootstrap_parentId);
} elseif ($type == static::TYPE_START) {
$column = array('id=?');
$values = array($model->bootstrap_parentId);
} else {
$column = array('id !=?', 'bootstrap_parentId=?', 'type=?');
$values = array($model->id, $model->bootstrap_parentId, $this->getTypeName($type));
}
$column[] = 'invisible=?';
$values[] = '';
return \ContentModel::countBy($column, $values);
}
示例4: countExistingTabSeparators
/**
* count existing tab separators elements
*
* @param ContentWrapper\Model $model
*
* @return int
*/
public function countExistingTabSeparators(ContentWrapper\Model $model)
{
$id = $model->getType() == ContentWrapper\Model::TYPE_START ? $model->id : $model->bootstrap_parentId;
$number = \ContentModel::countBy('type=? AND bootstrap_parentId', array($model->getTypeName(ContentWrapper\Model::TYPE_SEPARATOR), $id));
return $number;
}