a tiny mvc framework for php using php-activerecord
at v1 29 lines 845 B view raw
1<?php 2class 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 13 public function set_password($plaintext) 14 { 15 $this->encrypted_password = md5($plaintext); 16 } 17 18 public function set_name($value) 19 { 20 $value = strtoupper($value); 21 $this->assign_attribute('name',$value); 22 } 23 24 public function return_something() 25 { 26 return array("sharks" => "lasers"); 27 } 28}; 29?>