afterdead / db2php

Automatically exported from code.google.com/p/db2php
GNU General Public License v3.0
0 stars 0 forks source link

updateToDatabase(PDO $db) dont update a pk field #12

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
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.

Original issue reported on code.google.com by lurr....@gmail.com on 19 Apr 2010 at 1:15

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

Original comment by rc.poi...@gmail.com on 13 Jan 2012 at 8:32