A really small mistake - I wanted to run a MySQL update statement on laravel (no bindings, no parameters, no models) so I wrote this
DB::update(`UPDATE table SET something = 1 WHERE id = 1`);
When I ran this, I got this error
ValueError: PDO::prepare(): Argument #1 ($query) cannot be empty
Was a bit surprised to see this. Upon reading the documentation, you're supposed to run the query this way, for queries not returning any values
DB::statement('UPDATE table SET something = 1 WHERE id = 1');
Also, I had used backticks `` for the original longer SQL statement so that seemed to have caused on issue.
Top comments (0)