![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/framework/DB/Platform/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Framework\DB\Platform; use Magento\Framework\DB\Select; class Quote { /** * Return quoted identifier * * @param string $identifier * @return string */ public function quoteIdentifier($identifier) { return $this->quoteIdentifierAs($identifier); } /** * Return quoted column with alias * * @param string $identifier * @param string|null $alias * @return string */ public function quoteColumnAs($identifier, $alias = null) { return $this->quoteIdentifierAs($identifier, $alias); } /** * Return quoted table with alias * * @param string $identifier * @param string|null $alias * @return string */ public function quoteTableAs($identifier, $alias = null) { return $this->quoteIdentifierAs($identifier, $alias); } /** * Return quoted identifier with alias * * @param string $identifier * @param string|null $alias * @return string * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ protected function quoteIdentifierAs($identifier, $alias = null) { if ($identifier instanceof \Zend_Db_Expr) { $quoted = $identifier->__toString(); } elseif ($identifier instanceof \Magento\Framework\DB\Select) { $quoted = '(' . $identifier->assemble() . ')'; } else { if (is_string($identifier)) { $identifier = explode('.', $identifier); } if (is_array($identifier)) { $segments = []; foreach ($identifier as $segment) { if ($segment instanceof \Zend_Db_Expr) { $segments[] = $segment->__toString(); } else { $segments[] = $this->replaceQuoteSymbol($segment); } } if ($alias !== null && end($identifier) == $alias) { $alias = null; } $quoted = implode('.', $segments); } else { $quoted = $this->replaceQuoteSymbol($identifier); } } if ($alias !== null) { $quoted .= ' ' . Select::SQL_AS . ' ' . $this->replaceQuoteSymbol($alias); } return $quoted; } /** * Replace quote symbol * * @param string $value * @return string */ protected function replaceQuoteSymbol($value) { $symbol = $this->getQuoteIdentifierSymbol(); return ($symbol . str_replace("$symbol", "$symbol$symbol", (string)$value) . $symbol); } /** * Get quote identifier symbol * * @return string */ protected function getQuoteIdentifierSymbol() { return '`'; } }