Advertisement
Guest User

Untitled

a guest
May 18th, 2013
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.51 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4.  * EAV Debug
  5.  *
  6.  * Models is the same as used in example:
  7.  * http://fuelphp.com/docs/packages/orm/eav.html
  8.  *
  9.  * @author kimse
  10.  */
  11. class Controller_Eav extends \Controller_Rest
  12. {
  13.  
  14.     /**
  15.      * Update existing property on existing entity works
  16.      * EAV updated
  17.      */
  18.     public function get_find()
  19.     {
  20.         $mr = Model\Patient::find(1);
  21.  
  22.         $mr->Temperature = '36.1';
  23.  
  24.         if ($mr->save())
  25.         {
  26.             return $this->response($mr->to_array());
  27.         }
  28.         else
  29.         {
  30.             return $this->response(array('message' => 'error saving'));
  31.         }
  32.     }
  33.  
  34.     /**
  35.      * Adding new property on existing entity does not work
  36.      * EAV Age not added
  37.      */
  38.     public function get_find_set_new_attr()
  39.     {
  40.         $mr = Model\Patient::find(1);
  41.         $mr->Age = '86';
  42.  
  43.         if ($mr->save())
  44.         {
  45.             return $this->response($mr->to_array());
  46.         }
  47.         else
  48.         {
  49.             return $this->response(array('message' => 'error saving'));
  50.         }
  51.     }
  52.  
  53.     /**
  54.      * Creating new enitiy does not work
  55.      * EAV Headache not added
  56.      */
  57.     public function get_create()
  58.     {
  59.         $sir = new Model\Patient();
  60.         $sir->name = 'Sir. Illalot';
  61.         $sir->Headache = 'yes';
  62.  
  63.         if ($sir->save())
  64.         {
  65.             return $this->response($sir->to_array());
  66.         }
  67.         else
  68.         {
  69.             return $this->response(array('message' => 'error saving'));
  70.         }
  71.     }
  72.  
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement