当前位置: 首页>>代码示例>>PHP>>正文


PHP RedBeanModel::getCount方法代码示例

本文整理汇总了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);
                 }
             }
         }
     }
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:57,代码来源:ReadPermissionsOptimizationUtil.php

示例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;
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:18,代码来源:RedBeanModelsDataProvider.php

示例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;
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:17,代码来源:LatestActivitiesUtil.php


注:本文中的RedBeanModel::getCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。