3declare(strict_types=1);
28 public function select(array $ref_ids) : array
30 if (count($ref_ids) === 0) {
35 $query =
"SELECT ref_id, condition_operator, value" . PHP_EOL
36 .
"FROM " . static::TABLE_NAME . PHP_EOL
38 . implode(
',', $ref_ids)
42 while ($row = $this->db->fetchAssoc(
$result)) {
43 $data[$row[
'ref_id']] = [$row[
'condition_operator'], (int) $row[
'value']];
47 foreach ($ref_ids as $ref_id) {
53 if (array_key_exists($ref_id,
$data)) {
54 list($op, $value) =
$data[$ref_id];
56 $conditions[] = new \ilLSPostCondition($ref_id, $op, $value);
63 if (count($ref_ids) === 0) {
71 $query =
"DELETE FROM " . static::TABLE_NAME . PHP_EOL
73 . implode(
',', $ref_ids)
80 foreach ($ls_post_conditions as $condition) {
82 "ref_id" => array(
"integer", $condition->getRefId()),
83 "condition_operator" => array(
"text", $condition->getConditionOperator())
85 $db->insert(static::TABLE_NAME, $values);
92 public function upsert(array $ls_post_conditions)
94 if (count($ls_post_conditions) === 0) {
99 function ($condition) {
100 return (
int) $condition->getRefId();
105 $ilAtomQuery = $this->db->buildAtomQuery();
106 $ilAtomQuery->addTableLock(static::TABLE_NAME);
107 $ilAtomQuery->addQueryCallable(
109 $this->
delete($ref_ids,
$db);
An exception for terminatinating execution or to throw for unit testing.
Storage for ilLSPostConditions.
insert(array $ls_post_conditions, \ilDBInterface $db)
upsert(array $ls_post_conditions)
const STD_ALWAYS_OPERATOR
__construct(\ilDBInterface $db)