How-To: Create a REST API

Comparing #16 with #17

Revision #17 was created by jwerner jwerner on May 15, 2012, 7:21:34 PM.

Fixed typos. Thanks to waterloomatt

Content

[...]
$var, $_GET['model']) );
}
}
// Try to save the model
if($model->save())
$this->
_sendResponse(200, CJSON::encode($model));
else
// prepare the error $msg
[...]
$num = $model->delete();
if($num>0)
$this->
_sendResponse(200, $num); //this is the only way to work with backbone
else
$this->_sendResponse(500,
sprintf("Error: Couldn't delete model <b>%s</b> with ID <b>%s</b>.",
$_GET['model'], $_GET['id']) );
}
[...]