ILIAS  trunk Revision v11.0_alpha-2645-g16283d3b3f8
class.arJoin.php
Go to the documentation of this file.
1 <?php
2 
25 class arJoin extends arStatement
26 {
27  public const TYPE_NORMAL = self::TYPE_INNER;
28  public const TYPE_LEFT = 'LEFT';
29  public const TYPE_RIGHT = 'RIGHT';
30  public const TYPE_INNER = 'INNER';
31  public const AS_TEXT = ' AS ';
32  protected string $type = self::TYPE_NORMAL;
33  protected string $table_name = '';
34  protected array $fields = ['*'];
35  protected string $operator = '=';
36  protected string $on_first_field = '';
37  protected string $on_second_field = '';
38  protected bool $full_names = false;
39  protected bool $both_external = false;
40  protected bool $is_mapped = false;
41 
42  protected function asStatementText(ActiveRecord $activeRecord, ilDBInterface $db, string $as = ' AS '): string
43  {
44  $return = ' ' . $this->getType() . ' ';
45  $return .= ' JOIN ' . $this->getTableName() . $as . $this->getTableNameAs();
46  if ($this->getBothExternal()) {
47  $return .= ' ON ' . $this->wrapField($this->getOnFirstField(), $db) . ' ' . $this->getOperator() . ' ';
48  } else {
49  $return .= ' ON '
50  . $this->wrapField(
51  $activeRecord->getConnectorContainerName() . '.' . $this->getOnFirstField(),
52  $db
53  )
54  . ' ' . $this->getOperator() . ' ';
55  }
56 
57  return $return . $this->wrapField(
58  $this->getTableNameAs() . '.' .
59  $this->getOnSecondField(),
60  $db
61  );
62  }
63 
64  public function asSQLStatement(ActiveRecord $activeRecord, ilDBInterface $db): string
65  {
66  return $this->asStatementText($activeRecord, $db, self::AS_TEXT);
67  }
68 
69  public function setLeft(): void
70  {
71  $this->setType(self::TYPE_LEFT);
72  }
73 
74  public function setRght(): void
75  {
76  $this->setType(self::TYPE_RIGHT);
77  }
78 
79  public function setInner(): void
80  {
81  $this->setType(self::TYPE_INNER);
82  }
83 
87  public function setFields(array $fields): void
88  {
89  $this->fields = $fields;
90  }
91 
95  public function getFields(): array
96  {
97  return $this->fields;
98  }
99 
100  public function setOnFirstField(string $on_first_field): void
101  {
102  $this->on_first_field = $on_first_field;
103  }
104 
105  public function getOnFirstField(): string
106  {
107  return $this->on_first_field;
108  }
109 
110  public function setOnSecondField(string $on_second_field): void
111  {
112  $this->on_second_field = $on_second_field;
113  }
114 
115  public function getOnSecondField(): string
116  {
117  return $this->on_second_field;
118  }
119 
120  public function setOperator(string $operator): void
121  {
122  $this->operator = $operator;
123  }
124 
125  public function getOperator(): string
126  {
127  return $this->operator;
128  }
129 
130  public function setTableName(string $table_name): void
131  {
132  $this->table_name = $table_name;
133  }
134 
135  public function getTableName(): string
136  {
137  return $this->table_name;
138  }
139 
140  public function setType(string $type): void
141  {
142  $this->type = $type;
143  }
144 
145  public function getType(): string
146  {
147  return $this->type;
148  }
149 
150  public function setBothExternal(bool $both_external): void
151  {
152  $this->both_external = $both_external;
153  }
154 
155  public function getBothExternal(): bool
156  {
157  return $this->both_external;
158  }
159 
160  public function setFullNames(bool $full_names): void
161  {
162  $this->full_names = $full_names;
163  }
164 
165  public function getFullNames(): bool
166  {
167  return $this->full_names;
168  }
169 
170  public function isIsMapped(): bool
171  {
172  return $this->is_mapped;
173  }
174 
175  public function setIsMapped(bool $is_mapped): void
176  {
177  $this->is_mapped = $is_mapped;
178  }
179 }
setTableName(string $table_name)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
string $type
string $on_second_field
setOnSecondField(string $on_second_field)
array $fields
setBothExternal(bool $both_external)
const TYPE_LEFT
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
bool $is_mapped
getFullNames()
asStatementText(ActiveRecord $activeRecord, ilDBInterface $db, string $as=' AS ')
string $on_first_field
const TYPE_INNER
getTableName()
setType(string $type)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setOperator(string $operator)
const AS_TEXT
asSQLStatement(ActiveRecord $activeRecord, ilDBInterface $db)
wrapField(string $field, ilDBInterface $db)
getBothExternal()
string $table_name
const TYPE_NORMAL
setFullNames(bool $full_names)
bool $full_names
getConnectorContainerName()
Return the Name of your Connector Table
setOnFirstField(string $on_first_field)
getOnFirstField()
const TYPE_RIGHT
getOnSecondField()
bool $both_external
setFields(array $fields)
setIsMapped(bool $is_mapped)