Fix Poll\Save

This commit is contained in:
Visman 2020-11-19 16:06:07 +07:00
parent c2f9164cc1
commit 37d7b2af3c

View file

@ -22,14 +22,14 @@ class Save extends Action
throw new RuntimeException('The poll model has errors');
}
$old = $this->manager->Load->load($poll->id);
$old = $this->manager->Load->load($poll->tid);
if (! $old instanceof Poll) {
throw new RuntimeException('No such poll found');
}
$vars = [
':tid' => $poll->id,
':tid' => $poll->tid,
];
$queryIn = 'INSERT INTO ::poll (tid, question_id, field_id, qna_text, votes)
VALUES (?i:tid, ?i:qid, ?i:fid, ?s:qna, ?i:votes)';
@ -119,12 +119,12 @@ class Save extends Action
throw new RuntimeException('The poll model has errors');
}
if (null !== $this->manager->Load->load($poll->id)) {
if (null !== $this->manager->Load->load($poll->tid)) {
throw new RuntimeException('Such the poll already exists');
}
$vars = [
':tid' => $poll->id,
':tid' => $poll->tid,
];
$query = 'INSERT INTO ::poll (tid, question_id, field_id, qna_text, votes)
VALUES (?i:tid, ?i:qid, ?i:fid, ?s:qna, ?i:votes)';
@ -149,6 +149,6 @@ class Save extends Action
$poll->resModified();
return $poll->id;
return $poll->tid;
}
}