private function _updateSurvey(array $values, $userId)
    {
        if ($this->tracker->filterChangesOnly($this->_gemsSurvey, $values)) {

            if (\Gems_Tracker::$verbose) {
                $echo = '';
                foreach ($values as $key => $val) {
                    $old = isset($this->_gemsSurvey[$key]) ? $this->_gemsSurvey[$key] : null;
                    $echo .= $key . ': ' . $old . ' => ' . $val . "\n";
                }
                \MUtil_Echo::r($echo, 'Updated values for ' . $this->_surveyId);
            }

            if (! isset($values['gsu_changed'])) {
                $values['gsu_changed'] = new \MUtil_Db_Expr_CurrentTimestamp();
            }
            if (! isset($values['gsu_changed_by'])) {
                $values['gsu_changed_by'] = $userId;
            }

            if ($this->exists) {
                // Update values in this object
                $this->_gemsSurvey = $values + $this->_gemsSurvey;

                // return 1;
                return $this->db->update('gems__surveys', $values, array('gsu_id_survey = ?' => $this->_surveyId));

            } else {
                if (! isset($values['gsu_created'])) {
                    $values['gsu_created'] = new \MUtil_Db_Expr_CurrentTimestamp();
                }
                if (! isset($values['gsu_created_by'])) {
                    $values['gsu_created_by'] = $userId;
                }

                // Update values in this object
                $this->_gemsSurvey = $values + $this->_gemsSurvey;

                // Remove the Gems survey id
                unset($this->_gemsSurvey['gsu_id_survey']);

                $this->_surveyId = $this->db->insert('gems__surveys', $this->_gemsSurvey);
                $this->_gemsSurvey['gsu_id_survey'] = $this->_surveyId;
                $this->exists = true;

                return 1;
            }

        } else {
            return 0;
        }
    }
private function _updateSurvey(array $values, $userId)
    {
        if ($this->tracker->filterChangesOnly($this->_gemsSurvey, $values)) {

            if (\Gems_Tracker::$verbose) {
                $echo = '';
                foreach ($values as $key => $val) {
                    $old = isset($this->_gemsSurvey[$key]) ? $this->_gemsSurvey[$key] : null;
                    $echo .= $key . ': ' . $old . ' => ' . $val . "\n";
                }
                \MUtil_Echo::r($echo, 'Updated values for ' . $this->_surveyId);
            }

            if (! isset($values['gsu_changed'])) {
                $values['gsu_changed'] = new \MUtil_Db_Expr_CurrentTimestamp();
            }
            if (! isset($values['gsu_changed_by'])) {
                $values['gsu_changed_by'] = $userId;
            }

            if ($this->exists) {
                // Update values in this object
                $this->_gemsSurvey = $values + $this->_gemsSurvey;

                // return 1;
                return $this->db->update('gems__surveys', $values, array('gsu_id_survey = ?' => $this->_surveyId));

            } else {
                if (! isset($values['gsu_created'])) {
                    $values['gsu_created'] = new \MUtil_Db_Expr_CurrentTimestamp();
                }
                if (! isset($values['gsu_created_by'])) {
                    $values['gsu_created_by'] = $userId;
                }

                // Update values in this object
                $this->_gemsSurvey = $values + $this->_gemsSurvey;

                // Remove the Gems survey id
                unset($this->_gemsSurvey['gsu_id_survey']);

                $this->_surveyId = $this->db->insert('gems__surveys', $this->_gemsSurvey);
                $this->_gemsSurvey['gsu_id_survey'] = $this->_surveyId;
                $this->exists = true;

                return 1;
            }

        } else {
            return 0;
        }
    }
private function _updateSurvey ( array $ values , $ userId ) { if ( $ this -> tracker -> filterChangesOnly ( $ this -> _gemsSurvey , $ values ) ) { if ( \ Gems_Tracker :: $ verbose ) { $ echo = '' ; foreach ( $ values as $ key => $ val ) { $ old = isset ( $ this -> _gemsSurvey [ $ key ] ) ? $ this -> _gemsSurvey [ $ key ] : null ; $ echo .= $ key . ': ' . $ old . ' => ' . $ val . "\n" ; } \ MUtil_Echo :: r ( $ echo , 'Updated values for ' . $ this -> _surveyId ) ; } if ( ! isset ( $ values [ 'gsu_changed' ] ) ) { $ values [ 'gsu_changed' ] = new \ MUtil_Db_Expr_CurrentTimestamp ( ) ; } if ( ! isset ( $ values [ 'gsu_changed_by' ] ) ) { $ values [ 'gsu_changed_by' ] = $ userId ; } if ( $ this -> exists ) { // Update values in this object $ this -> _gemsSurvey = $ values + $ this -> _gemsSurvey ; // return 1; return $ this -> db -> update ( 'gems__surveys' , $ values , array ( 'gsu_id_survey = ?' => $ this -> _surveyId ) ) ; } else { if ( ! isset ( $ values [ 'gsu_created' ] ) ) { $ values [ 'gsu_created' ] = new \ MUtil_Db_Expr_CurrentTimestamp ( ) ; } if ( ! isset ( $ values [ 'gsu_created_by' ] ) ) { $ values [ 'gsu_created_by' ] = $ userId ; } // Update values in this object $ this -> _gemsSurvey = $ values + $ this -> _gemsSurvey ; // Remove the Gems survey id unset ( $ this -> _gemsSurvey [ 'gsu_id_survey' ] ) ; $ this -> _surveyId = $ this -> db -> insert ( 'gems__surveys' , $ this -> _gemsSurvey ) ; $ this -> _gemsSurvey [ 'gsu_id_survey' ] = $ this -> _surveyId ; $ this -> exists = true ; return 1 ; } } else { return 0 ; } }
Update the survey, both in the database and in memory.

@param array $values The values that this token should be set to
@param int $userId The current user
@return int 1 if data changed, 0 otherwise
Update the survey both in the database and in memory .