blob: e476d9b4361d7d327f5ea0739f46b3a144095d13 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
<?php
/**
* @class WhereSetQueryComponent
* A where query that may contain other where queries (in brackets).
* @see Query
*/
class WhereSetQueryComponent extends WhereQueryComponent
{
/**
* Construct a subset of wheres.
*
* @param array $wheres An array of WhereQueryComponent
* @param string $link_operator How this where clause links with the previous clause, eg. "and" "or"
*/
function __construct(array $wheres, $link_operator = "and")
{
$this->link_operator = sanitise_string($link_operator);
$this->wheres = $wheres;
}
public function toStringNoLink()
{
$cnt = 0;
$string = " (";
foreach ($this->wheres as $where) {
if (!($where instanceof WhereQueryComponent))
throw new DatabaseException(elgg_echo('DatabaseException:WhereSetNonQuery'));
if (!$cnt)
$string.= $where->toStringNoLink();
else
$string.=" $where ";
$cnt ++;
}
$string .= ")";
return $string;
}
}
|