Export to GitHub

db2php - issue #12

updateToDatabase(PDO $db) dont update a pk field


Posted on Apr 19, 2010 by Quick Elephant

What steps will reproduce the problem? 1.create a table with a pk 2.generate model 3.try to change the pk value with updateToDatabase(PDO $db)

What is the expected output? What do you see instead? a modified row with the new pk value

What version of the product are you using? On what operating system? 1.2.6.3 Windows 7 NetBeans 6.8

Please provide any additional information below. I've found the error in this code: public function updateToDatabase(PDO $db) { $stmt=self::prepareStatement($db,self::SQL_UPDATE); $this->bindValues($stmt); $stmt->bindValue(4,$this->getName()); $affected=$stmt->execute();

In case the pk value has changed, should use $this->OldInstance->getName(), since $this->getName() contains the new value.

Comment #1

Posted on Jan 13, 2012 by Grumpy Horse

Well, not really, the PK is used to identify the row. You have to delete the old one and create a new row instead

Status: WontFix

Labels:
Type-Defect Priority-Medium