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