Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2012
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.72 KB | None | 0 0
  1. Class Activity extends Article                                                                              
  2. {
  3.     /**    
  4.      * Post a new activity
  5.      */    
  6.     public static function newPost($heerId, $title, $contents, $date)                                                        
  7.     {                                                                                
  8.         $newInfo = array();
  9.         $newInfo['title'] = $title;                                                                              
  10.         $newInfo['contents'] = $contents;
  11.         $newInfo['date'] = $date;
  12.  
  13.         $this->fromArray($newInfo)                                                                        
  14.     }  
  15. }
  16.  
  17. Class Article extends DBObject
  18. {
  19.  
  20.     function __construct($source = null)
  21.     {  
  22.         $args = func_get_args();
  23.         if (count($args) > 1) {
  24.             call_user_func_array('newPost', $args);
  25.         } else {
  26.             parent::__construct($args);
  27.         }  
  28.     }  
  29. }
  30.  
  31. Class DBObject
  32. {
  33.     public $info;
  34.     public $changed;
  35.     public $changeSet;
  36.  
  37.     /**
  38.      * Construct a new database model object. You can pass either a key-value array
  39.      * or an sql query to the constructor.
  40.      * @param Array Key-Value based array containing all info
  41.      * @param Sql query where all values are replaced by %s %i etc., and provided
  42.      * as extra arguments.
  43.      */
  44.     function __construct($source = null)
  45.     {
  46.         if (is_array($source))
  47.             $this->fromArray($source);
  48.         else if ($source != null) {
  49.             $args = func_get_args();
  50.             $this->fromSql($args);
  51.         }
  52.  
  53.         if (!isset($this->info))
  54.             $this->info = Array();
  55.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement