2010年3月21日星期日

[fw-db] MSSQL - Zend_Db_Table_Abstract update() not binding params

Hi All,

I have been having some success in getting MSSQL 2008 and ZF 1.11.0dev
working together over PDO_MSSQL but have just hit a snag on my first
update() method.

I have a simple interface for managing countries as a test. The edit form
for this interface calls the following method in a class that extends
Zend_Db_Table_Abstract:

public function addCountry($countrycode, $countryname)
{
$data = array(
'countrycode' => $countrycode,
'countryname' => $countryname
);

$this->insert($data);
}

When this is run, I find the generated SQL is as follows:

UPDATE "eCountry" SET "countrycode" = ?, "countryname" = ? WHERE (countryid
= 0)

Now my first port of call was to step through the code to try to find the
problem. Which I did all the way down to Zend\DB\Adapter\Abstract.php's
query() method (line 467)

// prepare and execute the statement with profiling
$stmt = $this->prepare($sql);
$stmt->execute($bind);

Here I have output both the $sql and $bind vars. $sql is as it is above.
$bind contains the correct numerical array of parameters. So I guess the
problem lies in the execute($bind) method. This array is simply not binding
to the statement.

Insert and selects work just fine. I have not tried delete yet.

Has anyone come across this? I cannot find this execute() method, and the
prepare() method is just an Abstract signature.

I got this version of ZF from trunk, so the thought did cross my mind that I
had an unstable version.

Any suggestions would be appreciated. ZF is my last attempt at getting this
project rolling as MSSQL and PHP before having to go .NET.

Thanks
Aaron


--
View this message in context: http://n4.nabble.com/MSSQL-Zend-Db-Table-Abstract-update-not-binding-params-tp1677187p1677187.html
Sent from the Zend DB mailing list archive at Nabble.com.

没有评论: