Skip to content

Instantly share code, notes, and snippets.

@iammerrick
Created March 30, 2011 18:43
Show Gist options
  • Save iammerrick/894983 to your computer and use it in GitHub Desktop.
Save iammerrick/894983 to your computer and use it in GitHub Desktop.
<?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