Difference between #13 and #14 of
How-To: Create a REST API

Revision #14 has been created by jwerner on Jan 9, 2012, 11:00:15 PM with the memo:

Added note about logged-in user (Yii::app()->user)
« previous (#13) next (#15) »

Changes

Title unchanged

How-To: Create a REST API

Category unchanged

How-tos

Yii version unchanged

Tags unchanged

REST, API, Tutorial

Content changed

[...]
// ...
$this->_sendResponse(500, $msg );
}
```

Please keep in mind to check your model `beforeSave` and `afterSave` methods if any code eventually uses a logged-in user's id like the blog `Post` model:
 
 
 
```php 
protected function beforeSave()
 
{
 
    ...
 
    // author_id may have been posted via API POST
 
    if(is_null($this->author_id) or $this->author_id=='')
 
        $this->author_id=Yii::app()->user->id;
 
    ...
 
}
 
```
 

### Delete a Model Action


```php
public function actionDelete()
[...]
96 1
125 followers
Viewed: 376 345 times
Version: 1.1
Category: How-tos
Written by: jwerner
Last updated by: Rohit Suthar
Created on: Apr 15, 2011
Last updated: 3 years ago
Update Article

Revisions

View all history