docs/2.SAVING.md
## Saving data
For save data use __\vivace\db\Storage::save()__ method.
This method is responsible for both inserting and updating data.
An indexed array is used to store multiple rows.
An associative array is used to store single rows.
#### Insert one row
```php
$ok = $storage->save(['name' => 'Albert']);
```
#### Update one row
In this example data will be updated, because 'id' is a primary(unique) key
```php
$storage->save(['id' => 99, 'name' => 'Albert']);
```
#### Insert multiple rows
```php
$storage->save([
['name' => 'Albert'],
['name' => 'Marsel']
]);
```
#### Multiple upsert:
In the example below, the first row will be updated, because 'id' is primary key, and the first row will be saved
as new row (inserted)
```php
$storage->save([
['id' => 99, 'name' => 'Albert'],// first row
['name' => 'Marsel'] // second row
]);
```
For a better understanding, you can look at the following method
- __vivace\db\sql\Storage::save()__