1
votes

I needed to run composer update to install laravelcollectives. After running it I got:

QueryException in Connection.php line 651: SQLSTATE[42S22]: Column not found: 1054 Field'id' is unknown where clause (SQL: select * from users where id = 4 limit 1)

and:

PDOException in Connection.php line 319: SQLSTATE[42S22]: Column not found: 1054 field'id' is unknown where clause

There was no such error before the update. What could have gone wrong?!

1
Is there an id field in the users table?Matt
I take it that it's meant to be the auto incremented id field, it may be named differentlyMatt
No, there is not an id filed, there is userid...but before the update the field's name was the sameAlex
Try rename it as a basic test.Matt
Just renamed the field as id and everything worked. Unfortunately I want the field to be named userid cuz I have other IDs in the DB. What should I do to remain the field's name?Alex

1 Answers

1
votes

What you really did wrong is you ran composer update to install a package into a working project.

To install a new package into a already good working environment always use composer require vendor/package:2.* in your case e.g.:

composer require laravelcollective/html:5.2.*

Why never run composer update to install a package?

As the command update already says it updates every package required in your composer.json to the newest version (based on your minimum-stability and version tag). Yes it also installs new packages but if you run into errors after running update you never know what happened. Is it the new package which killed your working project or any of the also updated packages. So only run update if you really want to update and never if you want to install a package. Therefore use composer require as it only installs a new package but never touches existing packages.