ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.arStatement.php
Go to the documentation of this file.
1 <?php
2 
25 abstract class arStatement
26 {
27  protected string $table_name_as = '';
28 
29  abstract public function asSQLStatement(ActiveRecord $activeRecord, ilDBInterface $db): string;
30 
31  public function getTableNameAs(): string
32  {
33  return $this->table_name_as;
34  }
35 
36  public function setTableNameAs(string $table_name_as): void
37  {
38  $this->table_name_as = $table_name_as;
39  }
40 
41  protected function wrapFields(array $fields, ilDBInterface $db): array
42  {
43  $wrapped_fields = [];
44 
45  foreach ($fields as $field) {
46  if (empty($field)) {
47  continue;
48  }
49  $wrapped_fields[] = $this->wrapField($field, $db);
50  }
51 
52  return $wrapped_fields;
53  }
54 
55  protected function wrapField(string $field, ilDBInterface $db): string
56  {
57  $slitted = explode('.', $field);
58 
59  if (count($slitted) === 1 && $slitted[0] === '*') {
60  return $field;
61  }
62 
63  if (count($slitted) === 2) {
64  return $db->quoteIdentifier($slitted[0]) . '.' . $db->quoteIdentifier($slitted[1]);
65  }
66 
67  return $db->quoteIdentifier($field);
68  }
69 }
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...
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)