1
我正在嘗試創建RESTful API,並試圖通過Phalcon通過純查詢更新我的MySQL數據庫行。但我遇到了運行查詢的問題Phalcon status->success()
返回true,但是當我查看db值時,它們與之前相同。Phalcon MySQL UDPATE不能正常工作
我試圖從SQL查詢更改爲使用model->update()
,但具有相同的問題。值country_id
和university_id
是整數。
有沒有人有任何線索或解決方法?
我的POST處理功能:
$app->post("/api/user/university/{id:[0-9]+}", function($id) use ($app){
$university_id = $app->request->getPost("university_id");
$country_id = universities::findFirstById($university_id)->country_id;
$phpql = "UPDATE users
SET university_id=:university_id:,
country_id=:country_id:
WHERE
id=:user_id:";
$status = $app->modelsManager->executeQuery($phpql, array(
'user_id' => $id,
'university_id' => $university_id,
'country_id' => $country_id
));
$response = new Response();
if($status->success() == true){
$response->setStatusCode(201, "Created");
$response->setJsonContent(
array(
'status' => 0
)
);
} else {
$response->setStatusCode(409, "Conflict");
$errors = array();
foreach ($status->getMessages() as $message) {
$errors[] = $message->getMessage();
}
$response->setJsonContent(
array(
'status' => 'ERROR',
'messages' => $errors
)
);
}
return $response;
});
這應該是我對我的白癡抱歉.... – Mrnda