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


PHP Rule::findById方法代码示例

本文整理汇总了PHP中Rule::findById方法的典型用法代码示例。如果您正苦于以下问题:PHP Rule::findById方法的具体用法?PHP Rule::findById怎么用?PHP Rule::findById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Rule的用法示例。


在下文中一共展示了Rule::findById方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: doExecute

 protected function doExecute()
 {
     $id = $this->get('_id');
     $condId = $this->get('condId');
     $rule = Rule::findById($id);
     if ($rule) {
         //var_dump($rule);
         $exists = false;
         if (is_array($rule->conditions)) {
             foreach ($rule->conditions as $idx => $rc) {
                 if ($rc->condId == $condId) {
                     $exists = true;
                     array_splice($rule->conditions, $idx, 1);
                     break;
                 }
             }
         }
         if ($exists) {
             $ret = $rule->save();
             if ($ret) {
                 return $this->success($ret);
             } else {
                 return $this->error(ErrorInfo::ERROR_NO_DB_OPERATION_ERROR, 'add ruleCondition failed');
             }
         } else {
             return $this->error(ErrorInfo::ERROR_NO_DATA_NOT_FOUND, 'ruleCondition not found for _id=' . $id . ' and condId=' . $condId);
         }
     } else {
         return $this->error(ErrorInfo::ERROR_NO_DATA_NOT_FOUND, 'rule not found for _id=' . $id);
     }
 }
开发者ID:huhai463127310,项目名称:mockapi-php,代码行数:31,代码来源:RemoveRuleConditionPageService.php

示例2: doExecute

 protected function doExecute()
 {
     $id = $this->get('_id');
     $rule = Rule::findById($id);
     if ($rule) {
         $ruleCondition = RuleCondition::create($this->get('ruleCondition'));
         $exists = false;
         if ($ruleCondition->condId) {
             if (is_array($rule->conditions)) {
                 foreach ($rule->conditions as $key => $rc) {
                     if ($rc->condId == $ruleCondition->condId) {
                         $exists = true;
                         $rule->conditions[$key] = $ruleCondition;
                         break;
                     }
                 }
             }
         } else {
             $ruleCondition->condId = ObjectUtil::guid();
         }
         if (!$exists) {
             $rule->conditions[] = $ruleCondition;
         }
         $ret = $rule->save();
         if ($ret) {
             return $this->success($ret);
         } else {
             return $this->error(ErrorInfo::ERROR_NO_DB_OPERATION_ERROR, 'add ruleCondition failed');
         }
     } else {
         return $this->error(ErrorInfo::ERROR_NO_DATA_NOT_FOUND, 'rule not found for _id=' . $id);
     }
 }
开发者ID:huhai463127310,项目名称:mockapi-php,代码行数:33,代码来源:SaveRuleConditionPageService.php

示例3: doExecute

 protected function doExecute()
 {
     $rule = Rule::findById($this->get('_id'));
     if ($rule) {
         $ret = $rule->delete();
         if ($ret) {
             return $this->success($ret);
         } else {
             return $this->error(ErrorInfo::ERROR_NO_DB_OPERATION_ERROR, 'remove failed');
         }
     } else {
         return $this->error(ErrorInfo::ERROR_NO_DATA_NOT_FOUND, 'data not found');
     }
 }
开发者ID:huhai463127310,项目名称:mockapi-php,代码行数:14,代码来源:RemoveRulePageService.php

示例4: findRule

 private function findRule()
 {
     $rule = Rule::findById($this->getRequest()->get('_id'));
     return $this->success($rule);
 }
开发者ID:huhai463127310,项目名称:mockapi-php,代码行数:5,代码来源:TestRulePageService.php

示例5: doExecute

 protected function doExecute()
 {
     return $this->success(Rule::findById($this->get('_id')));
 }
开发者ID:huhai463127310,项目名称:mockapi-php,代码行数:4,代码来源:FindRuleByIdPageService.php


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