Revision #17 has been created by jwerner on May 15, 2012, 7:21:34 PM with the memo:
Fixed typos. Thanks to waterloomatt
« previous (#16) next (#18) »
Changes
Title
unchanged
How-To: Create a REST API
Category
unchanged
How-tos
Yii version
unchanged
Tags
unchanged
REST, API, Tutorial, Backbone
Content
changed
[...]
$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']) );
}[...]