mysql - Laravel Eloquent REPLACE -
i'm creating database migration script in laravel 4 command.
all database migration process fine i'm having trouble changing user prefixes: need change user-john-jb user-john-od, user suffixes need changes '-jb' '-od'.
the current line of code have is:
db::table('users')->update(['username' => db::raw("replace(username, '-".$suffix."', '-".$thissuffix."')")]);
if run code in repl works fine doesn't work in command.
looking @ logs generated sql query is:
update `users` set `username` = replace(username, "-jb ", "-od")
for reason line break being inserted query. i'm not sure if has problem.
does know how fix this? appreciated.
thanks in advance.
as ben harold pointed out, problem came $suffix containing line break. adding trim() fixed problem.
Comments
Post a Comment