Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
unioncondition.php
1
<?php
9
namespace
Bitrix\Main\ORM\Query
;
10
11
use
Bitrix\Main\ArgumentException
;
12
use
Bitrix\Main\DB\SqlExpression
;
13
20
class
UnionCondition
21
{
23
protected
$subQuery
;
24
26
protected
$all
;
27
34
public
function
__construct
(
$subQuery
, $unionAll =
false
)
35
{
36
if
(!(
$subQuery
instanceof
Query
) && !(
$subQuery
instanceof
SqlExpression
))
37
{
38
throw
new
ArgumentException
(
"Query or SqlExpression expected, `"
.gettype(
$subQuery
).
"` found."
);
39
}
40
41
$this->subQuery =
$subQuery
;
42
$this->all = $unionAll;
43
}
44
48
public
function
getSubQuery
()
49
{
50
return
$this->subQuery
;
51
}
52
56
public
function
setSubQuery
(
$subQuery
)
57
{
58
$this->subQuery =
$subQuery
;
59
}
60
64
public
function
isAll
()
65
{
66
return
$this->all
;
67
}
68
72
public
function
setAll
(
$all
)
73
{
74
$this->all =
$all
;
75
}
76
84
public
function
getSql
($forceObjectPrimary =
false
)
85
{
86
$sql =
"UNION "
;
87
88
if
($this->all)
89
{
90
$sql .=
"ALL "
;
91
}
92
93
$subQuerySql = $this->
getSubQuerySql
($forceObjectPrimary);
94
95
if
(preg_match(
'/(\sorder\s+by\s|\slimit\s+\d+)/i'
, $subQuerySql))
96
{
97
$subQuerySql =
"({$subQuerySql})"
;
98
}
99
100
return
$sql . $subQuerySql;
101
}
102
110
public
function
getSubQuerySql
($forceObjectPrimary =
false
)
111
{
112
if
($this->subQuery instanceof
Query
)
113
{
114
return
$this->subQuery->getQuery($forceObjectPrimary);
115
}
116
elseif ($this->subQuery instanceof
SqlExpression
)
117
{
118
return
$this->subQuery->compile();
119
}
120
121
return
null
;
122
}
123
}
Bitrix\Main\ArgumentException
Definition
exception.php:34
Bitrix\Main\DB\SqlExpression
Definition
sqlexpression.php:19
Bitrix\Main\ORM\Query\Query
Definition
query.php:118
Bitrix\Main\ORM\Query\UnionCondition
Definition
unioncondition.php:21
Bitrix\Main\ORM\Query\UnionCondition\$subQuery
$subQuery
Definition
unioncondition.php:23
Bitrix\Main\ORM\Query\UnionCondition\setSubQuery
setSubQuery($subQuery)
Definition
unioncondition.php:56
Bitrix\Main\ORM\Query\UnionCondition\getSql
getSql($forceObjectPrimary=false)
Definition
unioncondition.php:84
Bitrix\Main\ORM\Query\UnionCondition\getSubQuery
getSubQuery()
Definition
unioncondition.php:48
Bitrix\Main\ORM\Query\UnionCondition\$all
$all
Definition
unioncondition.php:26
Bitrix\Main\ORM\Query\UnionCondition\isAll
isAll()
Definition
unioncondition.php:64
Bitrix\Main\ORM\Query\UnionCondition\setAll
setAll($all)
Definition
unioncondition.php:72
Bitrix\Main\ORM\Query\UnionCondition\getSubQuerySql
getSubQuerySql($forceObjectPrimary=false)
Definition
unioncondition.php:110
Bitrix\Main\ORM\Query\UnionCondition\__construct
__construct($subQuery, $unionAll=false)
Definition
unioncondition.php:34
Bitrix\Main\ORM\Query
Definition
chain.php:3
modules
main
lib
orm
query
unioncondition.php
Создано системой
1.10.0