Did you run php artisan migrate on your production server, this can happens if you added the column later in the development, and it was not migrated in the development server, please check in your mysql client (phpmyadmin , sequelpro...) if the column actually exists in the database, before we explore other options
Strange Error with Laravel DB query
I really hope somebody on here could help me with this very strange issue.
I have an Laravel DB query which runs absolutely fine on my development host, however I get an error when I deploy it to my UAT host.
[EDIT - simplified example]
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'c.xxx' in 'order clause' (SQL: SELECT c.*
FROM (SELECT 0 AS xxx, u.* FROM users u) c
ORDER BY c.xxx DESC)
This would be absolutely fine if the SQL had an issue, however, it seems the SQL itself is absolutely fine too when I copy / paste it into workbench, but the PHP gives the above error.
I have reduced the query down to the minimum to demonstrate the issue.
[EDIT - simplified example]
return DB::select(" SELECT c.*
FROM (SELECT 0 AS xxx, u.* FROM users u) c
ORDER BY c.xxx DESC");
Here is the generated query. Replacing 'users' with any table really should run so I don't think its anything on the database level. The users table is no different to the one shipped with laravel auth.
SELECT c.*
FROM (SELECT 0 AS xxx,
u.*
FROM users u) c
ORDER BY c.xxx DESC
Any help much appreciated as I am stumped on this one...
Any ideas why the database query could possibly behave differently to the query run via Laravel / php? Any idea why one machine would behave fine and there other display the above error?
Please or to participate in this conversation.