Created
March 30, 2011 18:43
-
-
Save iammerrick/894983 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
$user = Cascade::factory(ORM::factory('user')); // Add functionality to the ORM class by decorating it with Cascade. | |
$user->username = 'iamauser'; | |
$user->profile->first_name = 'Merrick'; | |
$user->profile->last_name = 'Christensen'; | |
try | |
{ | |
$user->save(); // Saves and/or creates a user object and a profile object with the dependency that profile has on user. | |
} | |
catch(ORM_Validation_Exception $e) | |
{ | |
$errors = $e->errors('models'); // Combines profile and user errors | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment