Advertisement
Guest User

Untitled

a guest
Jun 12th, 2017
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.65 KB | None | 0 0
  1. $_POST = {
  2.     user = {
  3.         username: zeelot3k
  4.         password: awesomesauce
  5.         // Alias that is in the user model that points to user_profile model
  6.         profile = {
  7.             name: Lorenzo Pisani
  8.             address: 550 awesome street
  9.             aim: zeelot3k
  10.         }
  11.     }
  12. }
  13.  
  14. $user = ORM::factory('user');
  15.  
  16. // this is the array of values that will be set
  17. $expected = array(
  18.     'username',
  19.     'password',
  20.     // ORM will automatically look for related models
  21.     'profile' => array(
  22.         // Notice that the address will not be saved
  23.         'name',
  24.         'aim',
  25.     ),
  26. );
  27.  
  28. $user->values($_POST['user'], $expected);
  29. try{
  30.     $user->save(); 
  31. }catch (ORM_Validation_Exception $e){
  32.     $errors = $e->errors();
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement