Esempio n. 1
0
 public function set($value)
 {
     if ($value instanceof WaxModel) {
         $this->model->{$this->col_name} = $value->{$value->primary_key};
         return $this->model->save();
     } elseif (is_numeric($value)) {
         $this->model->{$this->col_name} = $value;
         return $this->model->save();
     }
     $class = get_class($this->model);
     WaxModel::unset_cache($class, $this->field, $this->model->{$this->col_name});
 }
Esempio n. 2
0
 public function set($value)
 {
     if ($value instanceof WaxModel) {
         $this->model->{$this->col_name} = $value->{$value->primary_key};
         return $this->model->save();
     } else {
         $obj = new $this->target_model($value);
         if ($obj->primval) {
             $this->model->{$this->col_name} = $value;
             return $this->model->save();
         }
     }
     $class = get_class($this->model);
     WaxModel::unset_cache($class, $this->field, $this->model->{$this->col_name});
 }
Esempio n. 3
0
 /**
  * filter on the join_model
  * IMPORTANT: will only work with array filters, text filters are passed on to the target model as usual
  * ALSO IMPORTANT: will not work if any of the defined filters are on columns not in the join model, in that case it will also pass on to the target model as usual
  *
  * @return WaxModelAssociation
  */
 public function filter($params, $value = NULL, $operator = "=")
 {
     if (is_array($params)) {
         foreach ($params as $column => $value) {
             if (!$this->join_model->columns[$column]) {
                 return $this->__call("filter", array($params, $value, $operator));
             }
         }
         $this->join_model->filter($params, $value, $operator);
         WaxModel::unset_cache(get_class($this->model), $this->field);
         return $this->get();
     } else {
         return $this->__call("filter", array($params, $value, $operator));
     }
 }