You are here

public function SelectQuery::addCondition in Salesforce Suite 8.4

Same name and namespace in other branches
  1. 8.3 src/SelectQuery.php \Drupal\salesforce\SelectQuery::addCondition()
  2. 5.0.x src/SelectQuery.php \Drupal\salesforce\SelectQuery::addCondition()

Add a condition to the query.

Parameters

string $field: Field name.

mixed $value: Condition value. If an array, it will be split into quote enclosed strings separated by commas inside of parenthesis. Note that the caller must enclose the value in quotes as needed by the SF API. NOTE: It is the responsibility of the caller to escape any single-quotes inside of string values.

string $operator: Conditional operator. One of '=', '!=', '<', '>', 'LIKE, 'IN', 'NOT IN'.

Return value

$this

File

src/SelectQuery.php, line 73

Class

SelectQuery
Class SelectQuery.

Namespace

Drupal\salesforce

Code

public function addCondition($field, $value, $operator = '=') {
  if (is_array($value)) {
    $value = "('" . implode("','", $value) . "')";

    // Set operator to IN if wasn't already changed from the default.
    if ($operator == '=') {
      $operator = 'IN';
    }
  }
  $this->conditions[] = [
    'field' => $field,
    'operator' => $operator,
    'value' => $value,
  ];
  return $this;
}