Question: I have a cakePHP problem - I want to make a update query like this

`UPDATE table SET field = field + some_var` 

and I don't know how to do it...

Can anyone help me?

Answer: 
There are two ways to do an update:

If you are only updating one field you can do:

```
$this->Model->id = foo;
$this->Model->saveField('field_name', 'field_value');

```

or, you can do an update using $this->Model->save():

```
$data = array(
    'Model'=>array(
        'id'=>foo,
        'field_name'=>'field_value',
        'another_field_name'=>'another_field_value'
    )
);

$this->Model->save($data);

```

You want to avoid using $this->Model->query() and use CakePHP's built in methods because the build in methods are datasource agnostic (they work the same on MySQL, Oracle, MSSQL etc.)
You can use the callback method beforeSave to implement what you need.

[Callback Method: BeforeSave](http://book.cakephp.org/2.0/en/models/callback-methods.html#beforesave)

```
public function beforeSave($options = array()) {
    if (!empty($this->data['table']['field'])){
         $this->data['table']['field'] += $this->data['table']['some_var'];
    }
    return true;
}

```