Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ConditionManager.php
Go to the documentation of this file.
1 <?php
7 
10 
20 {
21  const CONDITION_PATTERN_SIMPLE = '%s %s %s';
22  const CONDITION_PATTERN_ARRAY = '%s %s (%s)';
23 
27  private $connection;
28 
33  {
34  $this->connection = $resource->getConnection();
35  }
36 
43  public function wrapBrackets($query)
44  {
45  return empty($query)
46  ? $query
47  : '(' . $query . ')';
48  }
49 
57  public function combineQueries(array $queries, $unionOperator)
58  {
59  return implode(
60  ' ' . $unionOperator . ' ',
61  array_filter($queries, 'strlen')
62  );
63  }
64 
73  public function generateCondition($field, $operator, $value)
74  {
75  return sprintf(
76  is_array($value) ? self::CONDITION_PATTERN_ARRAY : self::CONDITION_PATTERN_SIMPLE,
77  $this->connection->quoteIdentifier($field),
78  $operator,
79  $this->connection->quote($value)
80  );
81  }
82 }
$resource
Definition: bulk.php:12
$value
Definition: gender.phtml:16