我正在使用Slim Framework进行路由和Postman更新数据,但它返回" Slim Application Error .." ..我哪里出错了?在我的插入它工作得很好
这是我的更新路线
//Update
$app->put('/citizens/update/{id}', function (Request $request, Response $response, array $args) {
$id = $request->getAttribute('id');
$fName = $request->getParam('f_name');
$mName = $request->getParam('m_name');
$lName = $request->getParam('l_name');
$updateData = Test::update($fName, $mName, $lName, $id);
});
这是我的更新测试类
public static function update($fName, $mName, $lName, $id)
{
$db = new DatabaseHandler;
$updateData = $db->update(TABLE, [
'f_name' => $fName,
'm_name' => $mName,
'l_name' => $lName,
])->where(['id' => $id])->save();
return $updateData;
}
这是我的更新查询处理程序
public function update($table, $conditions)
{
$this->query = "UPDATE ".$table." SET ";
foreach ($conditons as $column => $val)
{
$this->bind[] = $val;
$this->query = $this->query.$column.'=?';
if($counter+1 < count($conditions))
{
$this->query = $this->query.", ";
}
$counter++;
}
return $this;
}
public function where($conditions)
{
$this->query = $this->query." WHERE ";
foreach($conditions as $condition => $val)
{
$this->query = $this->query.$condition.'='.$val;
}
return $this;
}