Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takahashi-h5/03f23d419b7e515790b0bfaa9e2eb14b to your computer and use it in GitHub Desktop.
Save takahashi-h5/03f23d419b7e515790b0bfaa9e2eb14b to your computer and use it in GitHub Desktop.
$response = new Phalcon\Http\Response();
// $recordがexecuteQueryメソッドの戻り値
if ($record === false) {
$response->setStatusCode(404); 
$response->setJsonContent(
[
'status' => 'NOT-FOUND'
]
);
} else {
$response->setStatusCode(200);
$response->setJsonContent(
[
'status' => 'FOUND',
'data' => [
'id' => $record[0]->id,
'firstname' => $record[0]->firstname,
'lastname' => $record[0]->lastname,
'age' => $record[0]->age
]
]
);
}
return $response;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment