ZF2 ベースのフレームワーク 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()"