phone_number = $data['phone_number']; $this->invalid = $data['invalid']; $this->validation_errors = $data['validation_error']; $this->country_code = 0; if (!$this->invalid) { throw new \Exception('Validation failed'); } } public function prepareUpdate(): array { $params = $this->queryParams(); unset($params[':phone_number']); $params[':validation_errors'] = json_encode($params[':validation_errors']); $placeholders = array_keys($params); $updateString = $this->updateStringByPlaceholders($placeholders); return [$params, $updateString]; } public function updateEntityInDb(int $entityId, int $apiKey): void { [$params, $updateString] = $this->prepareUpdate(); $params['entity_id'] = $entityId; $params['key'] = $apiKey; // other params will stay still $query = (" UPDATE event_phone SET {$updateString} WHERE event_phone.id = :entity_id AND event_phone.key = :key "); $model = new \Models\Phone(); $model->execQuery($query, $params); } }