Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

appyapp's avatar

How to add a backslash in an insert query (ex App\User)

I have a specific requirement to run this query directly without using Eloquent ORM

                DB::insert("INSERT INTO projects SET
                    subject_type='App\Project',
                    causer_type='App\User',
                    created_at= NOW(),
                    updated_at= NOW()
                ");

It works but it doesn't add the back slash e.g App\User becomes AppUser. I tried adding two App\\User but it still added as AppUser.

Any ideas how to get it working?

Thanks

0 likes
1 reply
appyapp's avatar
appyapp
OP
Best Answer
Level 2

OK - after trying different methods I have got it working. It's simple

I just need to make it 3 slashes i.e. App\\\User and it saves App\User

Please or to participate in this conversation.