trendsideas's avatar

Delete problem DB record from SQlite in Tinker

Hi, while adding the user in PHP artisan tinker on laravel-5-from-scratch/episodes/10, I accidentally typed $username->username = 'JohnDoe'; instead of $user->username = 'JohnDoe'; So the $username does not exist and is therefore causing an issue when trying to save a user. How do I delete it? Thanks

0 likes
3 replies
spekkionu's avatar
Level 48

You can do a $user->find($id)->delete(); if you want to delete it in tinker.

You can also just run a delete query directory on the database itself using the sqlite cli or any database gui that supports sqlite.

trendsideas's avatar

Thanks, I tried that but if I run anything it says "PHP error: Undefined variable: user on line 1"

trendsideas's avatar

Hi, that might have worked, I kept on getting errors but then I tried creating new users and it worked. Thanks

Please or to participate in this conversation.