本文整理汇总了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);
}
}
示例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);
}
}
示例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');
}
}
示例4: findRule
private function findRule()
{
$rule = Rule::findById($this->getRequest()->get('_id'));
return $this->success($rule);
}
示例5: doExecute
protected function doExecute()
{
return $this->success(Rule::findById($this->get('_id')));
}