Попытка создать строку, используемую в URL для mysql. Swift добавляет \ ко всем 'в строке, как можно создать строку без escape-символов? - PullRequest
0 голосов
/ 17 апреля 2020
> updateString  String  "Update DataBase SET  fname = \'Jimmy \' where

company = \ 'Summer Coach \' "

Мне нужно" Обновить базу данных SET fname = 'Jimmy' где

company = 'Summer Coach' '

enter code here

, если companyNameIsDirty {updateString = updateString + ", company ='" + companyName.text! + "'"}, Если addressIsDirty {updateString = updateString + ", address1 =' "+ address.text! +" '"} if cityIsDirty {updateString = updateString +", city =' "+ city.text! +" '"} if stateIsDirty {updateString = updateString +", state =' "+ state.text! + "'"} if zipcodeIsDirty {updateString = updateString + ", zip ='" + zipcode.text! + "'"} if officephoneIsDirty {updateString = updateString + ", offphone ='" + officephone.text! + "'"}} если mobilephoneIsDirty {updateString = updateString + ", faxphone = '" + mobilephone.text! + "'"} if firstnameIsDirty {updateString = updateString + ", fname = '" + firstname.text! + "'"} if lastnameIsDirty {updateString = updateString + " , lname = '"+ lastname.text! +"' "} если emailIsDirty {updateString = updateString +", email = '"+ email.text! +"' "} если disclaimerIsDir ty {updateString = updateString + ", disclaimer = '" + disclaimer.text! + "'"}

           // take comma off front of updateString
           updateStringInstructions = String(updateString.dropFirst())



        updateString = "Update "+tableName+" SET "+updateStringInstructions
        // updateString MUST contain a "Where" cluase !! --------------\\
        updateString = updateString+" where company = '"+companyName.text!+"'"

        updateString = updateString.replacingOccurrences(of: "\'", with: "'", options: NSString.CompareOptions.literal, range:nil)
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...