Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Quote.php
Go to the documentation of this file.
1 <?php
7 
9 
13 class Quote
14 {
19  public function quoteIdentifier($identifier)
20  {
21  return $this->quoteIdentifierAs($identifier);
22  }
23 
29  public function quoteColumnAs($identifier, $alias = null)
30  {
31  return $this->quoteIdentifierAs($identifier, $alias);
32  }
33 
39  public function quoteTableAs($identifier, $alias = null)
40  {
41  return $this->quoteIdentifierAs($identifier, $alias);
42  }
43 
50  protected function quoteIdentifierAs($identifier, $alias = null)
51  {
52  if ($identifier instanceof \Zend_Db_Expr) {
53  $quoted = $identifier->__toString();
54  } elseif ($identifier instanceof \Magento\Framework\DB\Select) {
55  $quoted = '(' . $identifier->assemble() . ')';
56  } else {
57  if (is_string($identifier)) {
58  $identifier = explode('.', $identifier);
59  }
60  if (is_array($identifier)) {
61  $segments = [];
62  foreach ($identifier as $segment) {
63  if ($segment instanceof \Zend_Db_Expr) {
64  $segments[] = $segment->__toString();
65  } else {
66  $segments[] = $this->replaceQuoteSymbol($segment);
67  }
68  }
69  if ($alias !== null && end($identifier) == $alias) {
70  $alias = null;
71  }
72  $quoted = implode('.', $segments);
73  } else {
74  $quoted = $this->replaceQuoteSymbol($identifier);
75  }
76  }
77  if ($alias !== null) {
78  $quoted .= ' ' . Select::SQL_AS . ' ' . $this->replaceQuoteSymbol($alias);
79  }
80  return $quoted;
81  }
82 
87  protected function replaceQuoteSymbol($value)
88  {
89  $symbol = $this->getQuoteIdentifierSymbol();
90  return ($symbol . str_replace("$symbol", "$symbol$symbol", $value) . $symbol);
91  }
92 
96  protected function getQuoteIdentifierSymbol()
97  {
98  return '`';
99  }
100 }
const SQL_AS
Definition: Select.php:78
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
quoteTableAs($identifier, $alias=null)
Definition: Quote.php:39
$value
Definition: gender.phtml:16
quoteColumnAs($identifier, $alias=null)
Definition: Quote.php:29
quoteIdentifierAs($identifier, $alias=null)
Definition: Quote.php:50
if(!trim($html)) $alias
Definition: details.phtml:20