save
Upsert(Update/Insert) a record.
Usage:
$db->{table}->save($data);
// First we search our data
$news = $db->news->findOne(1);
if (empty($news)) {
// If not existing declare new data
$news = new News();
}
$news->name = 'My Name';
$news->status = 'ACTIVE'
$data = $db->news->save($news);
Return:
// If existing updates the record
{
id: 1,
name: 'My Name',
created_at: '..',
updated_at: '..',
deleted_at: null
}
// If not creates a new record
{
id: 2,
name: 'My Name',
created_at: '..',
updated_at: null,
deleted_at: null
}
Last updated