blob: 596ec39945e4663196f70fcba707311c4de04d65 (
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
41
42
43
44
45
46
47
48
49
50
51
52
53
|
<?php
namespace ipl\Sql;
/**
* Implementation for the {@link CommonTableExpressionInterface} to allow CTEs via {@link with()}
*/
trait CommonTableExpression
{
/**
* All CTEs
*
* [
* [$query, $alias, $recursive],
* ...
* ]
*
* @var array[]
*/
protected $with = [];
public function getWith()
{
return $this->with;
}
public function with(Select $query, $alias, $recursive = false)
{
$this->with[] = [$query, $alias, $recursive];
return $this;
}
public function resetWith()
{
$this->with = [];
return $this;
}
/**
* Clone the properties provided by this trait
*
* Shall be called by using classes in their __clone()
*/
protected function cloneCte()
{
foreach ($this->with as &$cte) {
$cte[0] = clone $cte[0];
}
unset($cte);
}
}
|