/** * @param AccountTwrValue $model * @return mixed */ public function save(AccountTwrValue $model) { $result = $this->fpdo->from($this->table)->where('date = DATE(?)', $model->getDate())->where('account_number', $model->getAccountNumber())->limit(1)->fetch('id'); return $result ? $this->update($result, $model) : $this->insert($model); }