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()"