Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ConcatExpression.php
Go to the documentation of this file.
1 <?php
7 
10 
15 {
19  protected $adapter;
20 
24  protected $columns;
25 
29  protected $separator;
30 
36  public function __construct(
38  array $columns,
39  $separator = ' '
40  ) {
41  $this->adapter = $resource->getConnection();
42  $this->columns = $columns;
43  $this->separator = $separator;
44  }
45 
52  public function __toString()
53  {
54  $columns = [];
55  foreach ($this->columns as $key => $part) {
56  if (isset($part['columnName']) && $part['columnName'] instanceof \Zend_Db_Expr) {
57  $column = $part['columnName'];
58  } else {
59  $column = $this->adapter->quoteIdentifier(
60  (isset($part['tableAlias']) ? $part['tableAlias'] . '.' : '')
61  . (isset($part['columnName']) ? $part['columnName'] : $key)
62  );
63  }
64  $columns[] = $this->adapter->getCheckSql($column . " <> ''", $column, 'NULL');
65  }
66  return sprintf(
67  'TRIM(%s)',
68  $this->adapter->getConcatSql($columns, $this->separator)
69  );
70  }
71 }
__construct(ResourceConnection $resource, array $columns, $separator=' ')
$resource
Definition: bulk.php:12