// First we search our data$news = $db->news->findOne(1);if (empty($news)) {// If not existing declare new data $news =newNews();}$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}