3 declare(strict_types=1);
39 public function select(array $ref_ids): array
41 if ($ref_ids === []) {
47 "SELECT ref_id, condition_operator, value" . PHP_EOL
48 .
"FROM " . static::TABLE_NAME . PHP_EOL
49 .
"WHERE ref_id IN (" . implode(
',', $ref_ids) .
")" . PHP_EOL
52 $result = $this->db->query(
$query);
54 while ($row = $this->db->fetchAssoc($result)) {
55 $data[$row[
'ref_id']] = [$row[
'condition_operator'], $row[
'value']];
61 $op = self::STD_ALWAYS_OPERATOR;
65 if (array_key_exists($ref_id,
$data)) {
68 $conditions[] = new \ilLSPostCondition($ref_id, $op, $value);
75 if ($ref_ids === []) {
84 "DELETE FROM " . static::TABLE_NAME . PHP_EOL
85 .
"WHERE ref_id IN (" . implode(
',', $ref_ids) .
")" . PHP_EOL
93 foreach ($ls_post_conditions as $condition) {
95 "ref_id" => [
"integer", $condition->getRefId()],
96 "condition_operator" => [
"text", $condition->getConditionOperator()],
97 "value" => [
"text", $condition->getValue()]
99 $db->
insert(static::TABLE_NAME, $values);
106 public function upsert(array $ls_post_conditions): void
108 if ($ls_post_conditions === []) {
112 $ref_ids = array_map(
117 $ilAtomQuery = $this->db->buildAtomQuery();
118 $ilAtomQuery->addTableLock(static::TABLE_NAME);
119 $ilAtomQuery->addQueryCallable(
120 function (
ilDBInterface $db) use ($ref_ids, $ls_post_conditions):
void {
121 $this->
delete($ref_ids,
$db);
122 $this->
insert($ls_post_conditions, $db);
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
insert(array $ls_post_conditions, ilDBInterface $db)
insert(string $table_name, array $values)
upsert(array $ls_post_conditions)
const STD_ALWAYS_OPERATOR
__construct(ilDBInterface $db)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...