ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.arStatement.php
Go to the documentation of this file.
1 <?php
2 
24 abstract class arStatement
25 {
26  protected string $table_name_as = '';
27 
28  abstract public function asSQLStatement(ActiveRecord $activeRecord, ilDBInterface $db): string;
29 
30  public function getTableNameAs(): string
31  {
32  return $this->table_name_as;
33  }
34 
35  public function setTableNameAs(string $table_name_as): void
36  {
37  $this->table_name_as = $table_name_as;
38  }
39 
40  protected function wrapFields(array $fields, ilDBInterface $db): array
41  {
42  $wrapped_fields = [];
43 
44  foreach ($fields as $field) {
45  $wrapped_fields[] = $this->wrapField($field, $db);
46  }
47 
48  return $wrapped_fields;
49  }
50 
51  protected function wrapField(string $field, ilDBInterface $db): string
52  {
53  $slitted = explode('.', $field);
54 
55  if (count($slitted) === 1 && $slitted[0] === '*') {
56  return $field;
57  }
58 
59  if (count($slitted) === 2) {
60  return $db->quoteIdentifier($slitted[0]) . '.' . $db->quoteIdentifier($slitted[1]);
61  }
62 
63  return $db->quoteIdentifier($field);
64  }
65 }
quoteIdentifier(string $identifier, bool $check_option=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
wrapFields(array $fields, ilDBInterface $db)
wrapField(string $field, ilDBInterface $db)
asSQLStatement(ActiveRecord $activeRecord, ilDBInterface $db)
setTableNameAs(string $table_name_as)