You are here

function field_validation_get_bundle_rules in Field Validation 7

Get an array of rules assigned to a field instance

File

./field_validation.rules.inc, line 36
provides API and management functions for the field validation rules

Code

function field_validation_get_bundle_rules($entity_type, $bundle) {
  $rules = array();
  $sql = "SELECT * FROM {field_validation_rule} WHERE entity_type = :entity_type AND bundle = :bundle ORDER BY ruleid DESC";
  $result = db_query($sql, array(
    ':entity_type' => $entity_type,
    ':bundle' => $bundle,
  ), array(
    'fetch' => PDO::FETCH_ASSOC,
  ));
  foreach ($result as $rule) {
    $rules[$rule['ruleid']] = $rule;
  }
  return $rules;
}