Advertisement
Guest User

Untitled

a guest
May 8th, 2014
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. class User extends Member {
  2. private static $db = array(
  3. "FirstName" => "Text",
  4. "Age" => "Int",
  5. "Address" => "Text"
  6. );
  7.  
  8. public static $has_one = array(
  9. 'Profile' => 'Profile'
  10. );
  11.  
  12.  
  13. public function onBeforeWrite()
  14. {
  15. parent::onBeforeWrite();
  16. if (! $this->Profile()->exists()) {
  17. $profile = new Profile();
  18. $profile->User = $this;
  19. $profile->write();
  20.  
  21. $this->ProfileID = $profile->ID
  22. }
  23. }
  24.  
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement