本文整理汇总了PHP中RedBeanModel::getCount方法的典型用法代码示例。如果您正苦于以下问题:PHP RedBeanModel::getCount方法的具体用法?PHP RedBeanModel::getCount怎么用?PHP RedBeanModel::getCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RedBeanModel
的用法示例。
在下文中一共展示了RedBeanModel::getCount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rebuildViaSlowWay
protected static function rebuildViaSlowWay($modelClassName)
{
// The slow way will remain here as documentation
// for what the optimized way is doing.
$mungeTableName = self::getMungeTableName($modelClassName);
self::recreateTable($mungeTableName);
//Specifically call RedBeanModel to avoid the use of the security in OwnedSecurableItem since for
//rebuild it needs to look at all models regardless of permissions of the current user.
$modelCount = RedBeanModel::getCount(null, null, $modelClassName);
$subset = intval($modelCount / 20);
if ($subset < 100) {
$subset = 100;
} elseif ($subset > 1000) {
$subset = 1000;
}
$users = User::getAll();
$groups = Group::getAll();
$roles = Role::getAll();
for ($i = 0; $i < $modelCount; $i += $subset) {
//Specifically call RedBeanModel to avoid the use of the security in OwnedSecurableItem since for
//rebuild it needs to look at all models regardless of permissions of the current user.
$models = RedBeanModel::getSubset(null, $i, $subset, null, null, $modelClassName);
foreach ($models as $model) {
assert('$model instanceof SecurableItem');
$securableItemId = $model->getClassId('SecurableItem');
foreach ($users as $user) {
list($allowPermissions, $denyPermissions) = $model->getExplicitActualPermissions($user);
$effectiveExplicitPermissions = $allowPermissions & ~$denyPermissions;
if (($effectiveExplicitPermissions & Permission::READ) == Permission::READ) {
self::incrementCount($mungeTableName, $securableItemId, $user);
}
}
foreach ($groups as $group) {
list($allowPermissions, $denyPermissions) = $model->getExplicitActualPermissions($group);
$effectiveExplicitPermissions = $allowPermissions & ~$denyPermissions;
if (($effectiveExplicitPermissions & Permission::READ) == Permission::READ) {
self::incrementCount($mungeTableName, $securableItemId, $group);
foreach ($group->users as $user) {
if ($user->role->id > 0) {
self::incrementParentRolesCounts($mungeTableName, $securableItemId, $user->role);
}
}
foreach ($group->groups as $subGroup) {
self::processNestedGroupWhereParentHasReadPermissionOnSecurableItem($mungeTableName, $securableItemId, $subGroup);
}
}
}
foreach ($roles as $role) {
$count = self::getRoleMungeCount($model, $role);
assert('$count >= 0');
if ($count > 0) {
self::setCount($mungeTableName, $securableItemId, $role, $count);
}
}
}
}
}
示例2: calculateTotalItemCount
/**
* This function is made public for unit testing. Calculates the total for each of the select statements
* and adds them up. Setting $selectDistinct to true when calling getCount since this is always true
* when counting ids.
* @return integer - total count across select statements.
*/
public function calculateTotalItemCount()
{
$totalCount = 0;
foreach ($this->modelClassNamesAndSearchAttributeData as $identifier => $modelClassNameAndSearchAttributeData) {
foreach ($modelClassNameAndSearchAttributeData as $modelClassName => $searchAttributeData) {
$joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter($modelClassName);
$where = ModelDataProviderUtil::makeWhere($modelClassName, $searchAttributeData, $joinTablesAdapter);
$totalCount = $totalCount + RedBeanModel::getCount($joinTablesAdapter, $where, $modelClassName, true);
}
}
return $totalCount;
}
示例3: getCountByModelClassName
public static function getCountByModelClassName($modelClassName, $relationItemIds, $ownedByFilter)
{
assert('is_string($modelClassName)');
assert('is_array($relationItemIds)');
assert('$ownedByFilter == LatestActivitiesConfigurationForm::OWNED_BY_FILTER_ALL ||
$ownedByFilter == LatestActivitiesConfigurationForm::OWNED_BY_FILTER_USER ||
is_int($ownedByFilter)');
$searchAttributeDataArray = static::getSearchAttributesDataByModelClassNamesAndRelatedItemIds(array($modelClassName), $relationItemIds, $ownedByFilter);
$joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter($modelClassName);
$where = ModelDataProviderUtil::makeWhere($modelClassName, $searchAttributeDataArray[0][$modelClassName], $joinTablesAdapter);
$count = RedBeanModel::getCount($joinTablesAdapter, $where, $modelClassName, true);
if (isset($searchAttributeDataArray[1][$modelClassName])) {
$where = ModelDataProviderUtil::makeWhere($modelClassName, $searchAttributeDataArray[1][$modelClassName], $joinTablesAdapter);
return $count + RedBeanModel::getCount($joinTablesAdapter, $where, $modelClassName, true);
}
return $count;
}