Having a problem with this here function. It's supposed to return a json string of data gathered using the sql call below. The problem is that I'm getting an error code "500" when accessing the page through my server (for example - localhost/app/API/states/Alabama/1/10.json). The odd thing is that the data is showing up as expected using both .json and without the appending .json. Controllers and Models are set up just fine as far as I can tell, yet the the error code remains:
{"code":500,"url":"/VOI2/API/states/Alabama/2/10.json","name":"SQLSTATE[42S22]: >Column not found: 1054 Unknown column 'states' in 'where >clause'","error":{"errorInfo":["42S22",1054,"Unknown column 'states' in 'where >clause'"]
public function index($stateName, $page, $limit = 10, $user = null) {
$this->State->recursive = 0;
$limit;
$set_limit = $page * $limit - ($limit);
$states = $this->State->query("SELECT *
FROM states, issues
WHERE stateName = '" . $stateName ."'
AND issues.state_id = states.id LIMIT " . $set_limit . "," . $limit)
$this->set('states', $this->paginate($states));
$this->set('_serialize', array('states'));
}
Issues is another table with model/controller. I wanted to have the urls setup in a meaningful manner is why I chose to separate states from issues. Thanks all for your help.