403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/main/lib/orm/query/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/main/lib/orm/query/unioncondition.php
<?php
/**
 * Bitrix Framework
 * @package    bitrix
 * @subpackage main
 * @copyright  2001-2017 Bitrix
 */

namespace Bitrix\Main\ORM\Query;

use Bitrix\Main\ArgumentException;
use Bitrix\Main\DB\SqlExpression;

/**
 * UNION container to be used in Query.
 *
 * @package    bitrix
 * @subpackage main
 */
class UnionCondition
{
	/** @var Query|SqlExpression */
	protected $subQuery;

	/** @var bool */
	protected $all;

	/**
	 * @param Query|SqlExpression $subQuery
	 * @param bool                $unionAll
	 *
	 * @throws ArgumentException
	 */
	public function __construct($subQuery, $unionAll = false)
	{
		if (!($subQuery instanceof Query) && !($subQuery instanceof SqlExpression))
		{
			throw new ArgumentException("Query or SqlExpression expected, `".gettype($subQuery)."` found.");
		}

		$this->subQuery = $subQuery;
		$this->all = $unionAll;
	}

	/**
	 * @return SqlExpression|Query
	 */
	public function getSubQuery()
	{
		return $this->subQuery;
	}

	/**
	 * @param SqlExpression|Query $subQuery
	 */
	public function setSubQuery($subQuery)
	{
		$this->subQuery = $subQuery;
	}

	/**
	 * @return bool
	 */
	public function isAll()
	{
		return $this->all;
	}

	/**
	 * @param bool $all
	 */
	public function setAll($all)
	{
		$this->all = $all;
	}

	/**
	 * @param bool $forceObjectPrimary
	 *
	 * @return string
	 * @throws ArgumentException
	 * @throws \Bitrix\Main\SystemException
	 */
	public function getSql($forceObjectPrimary = false)
	{
		$sql = "UNION ";

		if ($this->all)
		{
			$sql .= "ALL ";
		}

		$subQuerySql = $this->getSubQuerySql($forceObjectPrimary);

		if (preg_match('/(\sorder\s+by\s|\slimit\s+\d+)/i', $subQuerySql))
		{
			$subQuerySql = "({$subQuerySql})";
		}

		return $sql . $subQuerySql;
	}

	/**
	 * @param bool $forceObjectPrimary
	 *
	 * @return string
	 * @throws ArgumentException
	 * @throws \Bitrix\Main\SystemException
	 */
	public function getSubQuerySql($forceObjectPrimary = false)
	{
		if ($this->subQuery instanceof Query)
		{
			return $this->subQuery->getQuery($forceObjectPrimary);
		}
		elseif ($this->subQuery instanceof SqlExpression)
		{
			return $this->subQuery->compile();
		}

		return null;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit