Ich versuche, RESTful API zu erstellen, und ich versuche, meine MySQL-Datenbankzeile durch Phalcon über reine Abfragen zu aktualisieren. Aber ich laufe auf das Problem, dass die Abfrage ausgeführt wird Phalcon status->success()
gibt True zurück, aber wenn ich in die DB-Werte schaue, sind die gleichen wie zuvor.Phalcon MySQL UDPATE funktioniert nicht
Ich habe versucht, von SQL-Abfragen auf model->update()
zu ändern, hat aber das gleiche Problem. Beide Werte country_id
und university_id
sind ganze Zahlen.
Hat jemand irgendeine Ahnung oder Workaround?
Meine POST Handhabung Funktion:
$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;
});
dies sollte der Fall sein Es tut mir leid für meine Idiotie .... – Mrnda