Example #1
0
 public function __construct($set, $map, $data)
 {
     parent::__construct();
     parent::rqst();
     $this->set = $set;
     $this->map = $map;
     $this->data = $data[0];
     if (isset($_POST['crud'])) {
         $validation = crud_validation($this->map);
         $post = $validation['post'];
         $error = $validation['error'];
         $this->data = array_merge($this->data, $post);
         if ($error) {
             foreach ($error as $e => $v) {
                 $this->map[$e]['error'] = $v;
             }
         } else {
             switch ($post['method']) {
                 case 'edit':
                     $data = array_intersect_key($post, array_flip($this->set['cols']));
                     $this->update($this->set['tbl'], $data, $this->set['actionID'] . '=' . $post[$this->set['actionID']]);
                     break;
                     //                    case 'add':
                     //                        $this->update(REVIEWS_TABLE, $data, 'id=' . $data['id']);
                     //                        break;
             }
             $hook = $this->set['hook'];
             if ($hook) {
                 call_user_func($hook['func'], $this->data[$hook['param']]);
             }
             Redirect($this->build_url('delete'));
         }
     }
 }