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

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -