I am working on a Yii2 restful API and want to display data in JSON format. This is my structure database :
TABLE `volunteer`(
`volunteer_id` int(11) NOT NULL auto_increment,
`state_id` int(11) null
`nama` varchar(200) null
TABLE `state`(
`state_id` int(11) NOT NULL auto_increment,
`state` varchar(225) null
Basically, when I run in a browser with a specific ID = 1 ( http: //localhost/KDMA/web/index.php/volunteers/1 ), the data will be displayed as follows:
{
"volunteer_id": "1",
"state_id":"12",
"nama": "Bentong",
}
this result displays data from volunteer_id = 1. So, now I want to show data from state_id, not volunteer_id . For example, in SQL:
SELECT * FROM volunteer where state_id = 12;
What are the ways to solve my problem?
source
share