php - 苗条框架上的“更新查询”返回错误
问题描述
我使用 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;
}
解决方案
推荐阅读
- python-3.x - python3模块v:“module.classObj”
- python - 图像分类问题中 Raspberry Pi 0 上的 Tensorflow Lite 量化
- amazon-web-services - Correct Root CA for aswIoT mqtt server
- swift - 通用函数:表达式类型不明确,没有更多上下文
- amazon-web-services - 使用实例 ID 访问在 AWS 实例中运行的 WebService
- android - 使用 Jetpacks 导航组件时的奇怪片段生命周期
- python - PyMC3 和 Arviz:使用 arviz plot_hpd 可视化多种条件下的最高后验密度
- azure-functions - 有没有办法获取等待订阅的消息计数?
- javascript - 用于动态生成内容的自适应 vanilla JS 页面浏览器
- html - 悬停时的叠加层比图像宽