1 | <?php |
||
16 | class ReturnVars |
||
17 | { |
||
18 | /** |
||
19 | * @var string[] list of return variable expressions (for use in a SELECT or RETURNING clause) |
||
20 | */ |
||
21 | private $vars = []; |
||
22 | |||
23 | /** |
||
24 | * @var Type[] map where return variable name maps to Type |
||
25 | */ |
||
26 | private $type_map = []; |
||
27 | |||
28 | /** |
||
29 | * @var Table |
||
30 | */ |
||
31 | private $root; |
||
32 | |||
33 | /** |
||
34 | * @var Driver |
||
35 | */ |
||
36 | private $driver; |
||
37 | |||
38 | /** |
||
39 | * @var TypeProvider |
||
40 | */ |
||
41 | private $types; |
||
42 | |||
43 | /** |
||
44 | * @param Table $root |
||
45 | * @param Driver $driver |
||
46 | * @param TypeProvider $types |
||
47 | */ |
||
48 | 1 | public function __construct(Table $root, Driver $driver, TypeProvider $types) |
|
54 | |||
55 | /** |
||
56 | * Add all the Columns of a full Table to be selected and returned |
||
57 | * |
||
58 | * @param Table $table Table to select and return |
||
59 | */ |
||
60 | 1 | public function addTable(Table $table) |
|
66 | |||
67 | /** |
||
68 | * Add one or more Columns to select and return |
||
69 | * |
||
70 | * @param Column|Column[] one or more Columns to select and return |
||
71 | */ |
||
72 | 1 | public function addColumns($cols) |
|
98 | |||
99 | /** |
||
100 | * Add an SQL expression to select and return |
||
101 | * |
||
102 | * @param string $expr return expression |
||
103 | * @param string|null $name return variable name (optional, but usually required) |
||
104 | * @param Type|string|null $type optional Type (or Type class-name) |
||
105 | */ |
||
106 | 1 | public function addValue($expr, $name = null, $type = null) |
|
126 | |||
127 | /** |
||
128 | * @return TypeMapper |
||
129 | */ |
||
130 | 1 | public function createTypeMapper() |
|
143 | |||
144 | /** |
||
145 | * @return string comma-separated return expressions (for use in the SELECT or RETURNING clause of an SQL query) |
||
146 | */ |
||
147 | 1 | public function buildReturnVars() |
|
160 | |||
161 | /** |
||
162 | * Internally creates a full Type-map for all Columns in a given Table |
||
163 | * |
||
164 | * @param Table $table |
||
165 | * |
||
166 | * @return Type[] map where Column Alias maps to Type |
||
167 | */ |
||
168 | 1 | private function createTypeMap(Table $table) |
|
178 | } |
||
179 |