本文整理汇总了PHP中Rule::getRuleWithCriteriasAndActions方法的典型用法代码示例。如果您正苦于以下问题:PHP Rule::getRuleWithCriteriasAndActions方法的具体用法?PHP Rule::getRuleWithCriteriasAndActions怎么用?PHP Rule::getRuleWithCriteriasAndActions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rule
的用法示例。
在下文中一共展示了Rule::getRuleWithCriteriasAndActions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRulesForCriteria
/**
* Return all rules from database
*
* @param $crit array of criteria (at least, 'field' and 'value')
*
* @return array of Rule objects
**/
function getRulesForCriteria($crit)
{
global $DB;
$rules = array();
/// TODO : not working for SLALevels : no sub_type
//Get all the rules whose sub_type is $sub_type and entity is $ID
$query = "SELECT `" . $this->getTable() . "`.`id`\n FROM `" . getTableForItemType($this->ruleactionclass) . "`,\n `" . $this->getTable() . "`\n WHERE `" . getTableForItemType($this->ruleactionclass) . "`." . $this->rules_id_field . "\n = `" . $this->getTable() . "`.`id`\n AND `" . $this->getTable() . "`.`sub_type` = '" . get_class($this) . "'";
foreach ($crit as $field => $value) {
$query .= " AND `" . getTableForItemType($this->ruleactionclass) . "`.`{$field}` = '{$value}'";
}
foreach ($DB->request($query) as $rule) {
$affect_rule = new Rule();
$affect_rule->getRuleWithCriteriasAndActions($rule["id"], 0, 1);
$rules[] = $affect_rule;
}
return $rules;
}
示例2: getRulesForCriteria
/**
* Return all rules from database
*
* @param $crit array of criteria (at least, 'field' and 'value')
*
* @return array of Rule objects
**/
function getRulesForCriteria($crit)
{
global $DB;
$rules = array();
//Get all the rules whose sub_type is $sub_type and entity is $ID
$query = "SELECT `glpi_rules`.`id`\n FROM `glpi_ruleactions`,\n `glpi_rules`\n WHERE `glpi_ruleactions`." . $this->rules_id_field . " = `glpi_rules`.`id`\n AND `glpi_rules`.`sub_type` = '" . get_class($this) . "'";
foreach ($crit as $field => $value) {
$query .= " AND `glpi_ruleactions`.`{$field}` = '{$value}'";
}
foreach ($DB->request($query) as $rule) {
$affect_rule = new Rule();
$affect_rule->getRuleWithCriteriasAndActions($rule["id"], 0, 1);
$rules[] = $affect_rule;
}
return $rules;
}