53 private $selectRenderer;
68 self::$_partsInit = array_merge(self::$_partsInit, $parts);
69 if (!isset(self::$_partsInit[self::STRAIGHT_JOIN])) {
73 $this->selectRenderer = $selectRenderer;
132 foreach ($this->_parts[self::FROM] as $tableId => $tableProp) {
133 if ($tableProp[
'joinType'] == self::LEFT_JOIN) {
135 foreach ($this->_parts[self::COLUMNS] as $columnEntry) {
136 list($correlationName, $column) = $columnEntry;
142 $tableProp[
'tableName'],
149 if ($correlationName == $tableId) {
154 foreach ($this->_parts[self::WHERE] as $where) {
159 $tableProp[
'tableName'],
167 $joinUseInCond = $useJoin;
170 foreach ($this->_parts[self::FROM] as $tableCorrelationName =>
$table) {
171 if ($tableCorrelationName == $tableId) {
174 if (!empty(
$table[
'joinCondition'])) {
179 $tableProp[
'tableName'],
184 $joinInTables[] = $tableCorrelationName;
190 unset($this->_parts[self::FROM][$tableId]);
192 $this->_parts[
self::FROM][$tableId][
'useInCond'] = $joinUseInCond;
193 $this->_parts[
self::FROM][$tableId][
'joinInTables'] = $joinInTables;
210 foreach ($this->_parts[self::FROM] as $tableId => $tableProp) {
211 if ($tableProp[
'joinType'] == self::LEFT_JOIN) {
212 if ($tableProp[
'useInCond']) {
217 foreach ($tableProp[
'joinInTables'] as
$table) {
218 if (isset($this->_parts[self::FROM][
$table])) {
225 unset($this->_parts[self::FROM][$tableId]);
243 $quote = $this->_adapter->getQuoteIdentifierSymbol();
265 foreach ($needle as $position) {
266 if ($position == 0) {
269 if (!preg_match(
'#[a-z0-9_]#is', substr($cond, $position - 1, 1))) {
295 if (
$type == self::INNER_JOIN && empty($cond)) {
311 $this->
reset(self::LIMIT_COUNT);
315 if ($offset ===
null) {
316 $this->
reset(self::LIMIT_OFFSET);
381 $part = strtolower($part);
382 if (!array_key_exists($part, $this->_parts)) {
383 throw new \Zend_Db_Select_Exception(
"Invalid Select part '{$part}'");
385 $this->_parts[$part] =
$value;
409 if ($this->_adapter->supportStraightJoin() && !empty($this->_parts[self::STRAIGHT_JOIN])) {
426 protected function _tableCols($correlationName, $cols, $afterCorrelationName =
null)
428 if (!is_array($cols)) {
432 foreach ($cols as $k => $v) {
433 if ($v instanceof
Select) {
434 $cols[$k] = new \Zend_Db_Expr(sprintf(
'(%s)', $v->assemble()));
438 return parent::_tableCols($correlationName, $cols, $afterCorrelationName);
449 $this->_adapter->orderRand($this, $field);
461 if ($this->_parts[self::FOR_UPDATE]) {
462 $sql = $this->_adapter->forUpdate($sql);
479 $exists =
'EXISTS (%s)';
481 $exists =
'NOT EXISTS (%s)';
485 $exists = sprintf($exists,
$select->assemble());
487 $this->
where($exists);
509 return $this->selectRenderer->render($this);
538 $this->_adapter =
$objectManager->get(ResourceConnection::class)->getConnection();
elseif(isset( $params[ 'redirect_parent']))
exists($select, $joinCondition, $isExists=true)
_join($type, $name, $cond, $cols, $schema=null)
useStraightJoin($flag=true)
insertFromSelect($tableName, $fields=[], $onDuplicate=true)
__construct(\Magento\Framework\DB\Adapter\Pdo\Mysql $adapter, \Magento\Framework\DB\Select\SelectRenderer $selectRenderer, $parts=[])
_renderStraightjoin($sql)
crossUpdateFromSelect($table)
where($cond, $value=null, $type=null)
if($exist=($block->getProductCollection() && $block->getProductCollection() ->getSize())) $mode
limit($count=null, $offset=null)
_findTableInCond($table, $cond)
const INSERT_ON_DUPLICATE
insertIgnoreFromSelect($tableName, $fields=[])
_tableCols($correlationName, $cols, $afterCorrelationName=null)
if(!isset($_GET['name'])) $name