Author.php 845 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. class Author extends ActiveRecord\Model
  3. {
  4. static $pk = 'author_id';
  5. // static $has_one = array(array('awesome_person', 'foreign_key' => 'author_id', 'primary_key' => 'author_id'),
  6. // array('parent_author', 'class_name' => 'Author', 'foreign_key' => 'parent_author_id'));
  7. static $has_many = array('books');
  8. static $has_one = array(
  9. array('awesome_person', 'foreign_key' => 'author_id', 'primary_key' => 'author_id'),
  10. array('parent_author', 'class_name' => 'Author', 'foreign_key' => 'parent_author_id'));
  11. static $belongs_to = array();
  12. public function set_password($plaintext)
  13. {
  14. $this->encrypted_password = md5($plaintext);
  15. }
  16. public function set_name($value)
  17. {
  18. $value = strtoupper($value);
  19. $this->assign_attribute('name',$value);
  20. }
  21. public function return_something()
  22. {
  23. return array("sharks" => "lasers");
  24. }
  25. };
  26. ?>