/** * Perform a remote update request using the REST "put" method. * Note that this method will update *all* this model object's fields * that are included in this model object's data array - see fields(). * You can override this by providing an arg list of fields to update. * * @return Remote this object for method chaining, or NULL on failure */ public function update_all_fields() { if (!is_object($this->object)) { return NULL; } if (!$this->object->id) { return NULL; } if (!$this->is_validated()) { return NULL; } $fields = func_get_args(); $count = count($fields); if ($count == 0) { $fields = $this->fields(); } elseif ($count == 1 && is_array($fields[0])) { $fields = $fields[0]; } $fields[] = $this->object->get_id_field(); // can't update without $url = $this->secure_url() . '/' . $this->object->id; $data = array($this->get_class() => $this->object->data($fields)); $data[self::DB] = $this->get_database(); if ($this->response = REST::put($url, $data, $this->type)) { $this->check_response(); } $this->object->changed = array(); return $this; }