creating answer set doesn't work
Permalink Browser Info Environment
sixeightAnswerSet::create() is broken. The problem is in this part of the method:
$db->execute("INSERT INTO sixeightformsAnswerSets (asID,fID,dateSubmitted,dateUpdated,ipAddress,creator,editCode,amountCharged,isApproved,cID,recordID) VALUES (0,?,?,?,?,?,?,?,?,?,?)",array($fID,$timestamp,time(),$ipAddress,$uID,$editCode,$totalPrice,$approvalStatus,$cID,$recordID));
if($recordID == 0) {
$db->execute("UPDATE sixeightformsAnswerSets SET recordID = ? WHERE asID = ?",array($db->Insert_ID(),$db->Insert_ID()));
}
$as = sixeightAnswerSet::getByID($db->Insert_ID(),0,$getAnswers);
return $as;
After the UPDATE sql statement $db->Insert_ID() no longer returns a value. It appears that UPDATE resets it. The fix is to record $db->Insert_ID() into it's own variable after the insert and pass that into sixeightAnswerSet::getByID() instead of passing $db->Insert_ID()
$db->execute("INSERT INTO sixeightformsAnswerSets (asID,fID,dateSubmitted,dateUpdated,ipAddress,creator,editCode,amountCharged,isApproved,cID,recordID) VALUES (0,?,?,?,?,?,?,?,?,?,?)",array($fID,$timestamp,time(),$ipAddress,$uID,$editCode,$totalPrice,$approvalStatus,$cID,$recordID));
if($recordID == 0) {
$db->execute("UPDATE sixeightformsAnswerSets SET recordID = ? WHERE asID = ?",array($db->Insert_ID(),$db->Insert_ID()));
}
$as = sixeightAnswerSet::getByID($db->Insert_ID(),0,$getAnswers);
return $as;
After the UPDATE sql statement $db->Insert_ID() no longer returns a value. It appears that UPDATE resets it. The fix is to record $db->Insert_ID() into it's own variable after the insert and pass that into sixeightAnswerSet::getByID() instead of passing $db->Insert_ID()
Type: | Discussion |
---|---|
Status: | New |