1. EMYSSQLib
- Posted by mcwong Nov 27, 2008
- 945 views
- Last edited Nov 28, 2008
I managed to use the EMYSQLib to connect to a MySQL 5.0 database. While trying to insert into a table some rows were missing but no error message. I managed to trace this to the apostrophe characters in some text fields. The wrapper functions in MYSQLib contributed by Fabio Ramirez is excellent but missing the mysql_escape_string function. I tried wrapping that function but failed. Anyway, I managed to simulate that and here is the code in case someone else needs to do the same.
function to replace apostrophes in text fields for INSERT to mysql
global function replace_apos(sequence oldstr)
integer len, oi, ni sequence newstr
oi = 1 ni = 1 len = length(oldstr) newstr={}
while (oi <= len) do if (oldstr[oi] = 39) then newstr = newstr & {92} ni = ni + 1 newstr = newstr & {39} else newstr = newstr & oldstr[oi] end if oi = oi+1 ni = ni+1
end while
return newstr
end function