Skip to content

Commit ad22dfe

Browse files
committed
fix(section): unsupported use of QueryExpression
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
1 parent e26a4eb commit ad22dfe

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

inc/section.class.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,21 @@ public function post_purgeItem() {
148148
global $DB;
149149

150150
$formFk = PluginFormcreatorForm::getForeignKeyField();
151-
$DB->update(
152-
self::getTable(),
153-
new QueryExpression("`order` = `order` - 1"),
154-
[
151+
$rows = $DB->request([
152+
'SELECT' => 'id',
153+
'FROM' => self::getTable(),
154+
'WHERE' => [
155155
'order' => ['>', $this->fields['order']],
156156
$formFk => $this->fields[$formFk]
157-
]
158-
);
157+
],
158+
]);
159+
$section = new self();
160+
foreach($rows as $row) {
161+
$section->update([
162+
'id' => $row['id'],
163+
'order' => $section->fields['order'] - 1,
164+
]);
165+
}
159166

160167
$sectionFk = PluginFormcreatorSection::getForeignKeyField();
161168
$question = new PluginFormcreatorQuestion();

0 commit comments

Comments
 (0)