Skip to content

Commit

Permalink
fix(section): unsupported use of QueryExpression
Browse files Browse the repository at this point in the history
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
  • Loading branch information
btry committed Jun 4, 2020
1 parent 9865058 commit 8e40be8
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions inc/section.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,21 @@ public function post_purgeItem() {
global $DB;

$formFk = PluginFormcreatorForm::getForeignKeyField();
$DB->update(
self::getTable(),
new QueryExpression("`order` = `order` - 1"),
[
$rows = $DB->request([
'SELECT' => 'id',
'FROM' => self::getTable(),
'WHERE' => [
'order' => ['>', $this->fields['order']],
$formFk => $this->fields[$formFk]
]
);
],
]);
$section = new self();
foreach($rows as $row) {
$section->update([
'id' => $row['id'],
'order' => $section->fields['order'] - 1,
]);
}

$sectionFk = PluginFormcreatorSection::getForeignKeyField();
$question = new PluginFormcreatorQuestion();
Expand Down

0 comments on commit 8e40be8

Please sign in to comment.