简体   繁体   English

Zend db-更新不起作用

[英]Zend db - UPDATE does not work

I'm using Zend db to update a record in a MySQL table. 我正在使用Zend db更新MySQL表中的记录。 I have a SELECT that gets a uuid; 我有一个得到uuid的SELECT; and then the following to update the same record: 然后执行以下操作以更新相同的记录:

$data = array(
    'fieldname' => 'foobar',
);

$where = array();
$where["uuid = ?"] = $uuid;

$db->update('customers', $data, $where);

Unfortunately the record does not update, and I don't get an error message. 不幸的是,记录没有更新,并且我没有收到错误消息。 The uuid is correct. uuid是正确的。

I think I was missing the execute. 我想我错过了执行。 I ended up doing something like this: 我最终做了这样的事情:

$update = $db->update('customers');
$update->where(['uuid' => $uuid]);
$update->set(['fieldname' => 'foobar']);

$statement = $db->prepareStatementForSqlObject($update);
$results = $statement->execute();

This worked fine. 这很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM