lithium\data\source\Http::update PHP Method

update() public method

Update used by model to PUT.
public update ( object $query, array $options = [] ) : string
$query object
$options array
return string
    public function update($query, array $options = array())
    {
        $query = !is_object($query) ? new Query() : $query;
        $query->method() ?: $query->method("put");
        $query->path() ?: $query->path("/{:source}/{:id}");
        return $this->_filter(__METHOD__, array($query, $options), function ($self, $params) {
            list($query, $options) = $params;
            return $self->send($query, $options);
        });
    }

Usage Example

Beispiel #1
0
 public function testUpdateWithModel()
 {
     $http = new Http($this->_testConfig);
     $query = new Query(array('model' => $this->_model, 'data' => array('id' => '1', 'title' => 'Test Title')));
     $result = $http->update($query);
     $expected = join("\r\n", array('PUT /posts/1 HTTP/1.1', 'Host: localhost:80', 'Connection: Close', 'User-Agent: Mozilla/5.0', 'Content-Type: application/x-www-form-urlencoded', 'Content-Length: 16', '', 'title=Test+Title'));
     $result = (string) $http->last->request;
     $this->assertEqual($expected, $result);
 }