Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * EAV Debug
- *
- * Models is the same as used in example:
- * http://fuelphp.com/docs/packages/orm/eav.html
- *
- * @author kimse
- */
- class Controller_Eav extends \Controller_Rest
- {
- /**
- * Update existing property on existing entity works
- * EAV updated
- */
- public function get_find()
- {
- $mr = Model\Patient::find(1);
- $mr->Temperature = '36.1';
- if ($mr->save())
- {
- return $this->response($mr->to_array());
- }
- else
- {
- return $this->response(array('message' => 'error saving'));
- }
- }
- /**
- * Adding new property on existing entity does not work
- * EAV Age not added
- */
- public function get_find_set_new_attr()
- {
- $mr = Model\Patient::find(1);
- $mr->Age = '86';
- if ($mr->save())
- {
- return $this->response($mr->to_array());
- }
- else
- {
- return $this->response(array('message' => 'error saving'));
- }
- }
- /**
- * Creating new enitiy does not work
- * EAV Headache not added
- */
- public function get_create()
- {
- $sir = new Model\Patient();
- $sir->name = 'Sir. Illalot';
- $sir->Headache = 'yes';
- if ($sir->save())
- {
- return $this->response($sir->to_array());
- }
- else
- {
- return $this->response(array('message' => 'error saving'));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement