Created
March 21, 2020 06:46
-
-
Save takahashi-h5/03f23d419b7e515790b0bfaa9e2eb14b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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