This repository has been archived by the owner on Dec 6, 2017. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
078aa1e
commit 69e8551
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,31 @@ | |||
# Sleepy - A Restful Modeler | |||
|
|||
<?php | |||
|
|||
class Model_User extends Sleepy { | |||
|
|||
protected $_data_url = 'http://restfulserver.com/user/'; | |||
|
|||
protected $_data = array( | |||
'id' => '', | |||
'username' => '', | |||
'email' => '', | |||
); | |||
} | |||
|
|||
$user = Sleepy::factory('user'); | |||
$user->load(); // Runs a GET method on the $_data_url and updates the data. | |||
|
|||
$user->username = 'iammerrick'; // Change the user name. | |||
|
|||
$user->save(); // Posts the updated $_data via to the $_data_url | |||
|
|||
Sleep::factory('user') | |||
->set_fields($_POST, array('username', 'email')) | |||
->save(); // Posts the $_data via JSON to the $_data_url and sets $_data with the JSON response | |||
|
|||
|
|||
|
|||
|
|||
|
|||
?> |