/** * @param array $data * @param String $where * @return int */ public function update(array $data, $where) { foreach ($data as $key => $value) { $dataToStore = ['user_id' => $this->user->userid, 'profilefield_id' => $key, 'value' => $value]; $query = $this->getAdapter()->select()->from(['p' => $this->getTableName()])->where('profilefield_id = ' . $key . ' AND user_id = ' . $this->user->userid); $result = $this->getAdapter()->fetchOne($query); if ($result === false) { $this->insert($dataToStore); } else { parent::update($dataToStore, 'profilefield_id = ' . $key . ' AND user_id = ' . $this->user->userid); } } }