Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $_POST = {
- user = {
- username: zeelot3k
- password: awesomesauce
- // Alias that is in the user model that points to user_profile model
- profile = {
- name: Lorenzo Pisani
- address: 550 awesome street
- aim: zeelot3k
- }
- }
- }
- $user = ORM::factory('user');
- // this is the array of values that will be set
- $expected = array(
- 'username',
- 'password',
- // ORM will automatically look for related models
- 'profile' => array(
- // Notice that the address will not be saved
- 'name',
- 'aim',
- ),
- );
- $user->values($_POST['user'], $expected);
- try{
- $user->save();
- }catch (ORM_Validation_Exception $e){
- $errors = $e->errors();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement