1
我正在尝试使用基于ZF2的框架Apigility更新数据库中的一行。ZF2 aka更新SQL数据库条目的Apigility
我看到行存在,检索它的内容,并更新对象..但是当我试图做$table->update($arrayOfRowData);
我得到一个异常;
有关如何使用Update()
的文档有点稀疏..我是否需要将where=
子句放入? ?难道我需要在where子句匹配了所有表的主键(主键使用3列)
try {
// if an entry already exists, update it
$existingRow = $this->currentEntryExists($ff_user_id, $subvalue);
if($existingRow != false){
$fieldType = $this->transformer->mapField($key);
$existingRow[$fieldType] = $subvalue['value'];
$this->update($existingRow, $where = array('field_id' => $existingRow['field_id'], 'user_id' => $user_id, 'field_date' => $subvalue['dateTime']));
}else{
$fieldType = $this->transformer->mapField($key);
$dataArray = array('user_id' => $user_id,
'field_date' => $subvalue['dateTime'],
$fieldType => $subvalue['value']);
$result = $this->insert($dataArray);
}
} catch (Exception $e) {
$logger = $this->getServicesLogger();
$logger->err($e);
throw $e;
}
抛出异常:
"type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html",
"title": "Internal Server Error",
"status": 500,
"detail": "Invalid magic property access in Zend\\Db\\TableGateway\\AbstractTableGateway::__get()"