php - Laravel Model::find() throws SQLSTATE error -
i'm trying fetch record database using eloquent crm. table's primary key field name "user_id". weird thing everytime use user::find() , pass user_id number,
sqlstate[42s22]: column not found: 1054 unknown column 'id' in 'where clause' (sql: select * `users` `id` = ? limit 1) (bindings: array ( 0 => 8, )) i'm assuming orm makes calls assuming table's id field name "id" instead of "user_id". how can check correctly sees supposed see. tried change primary key field user_id "id" orm seem expect , worked i'm following naming convention in database schema stick "user_id".
any form of appreciated.
thanks
i have fixed problem. had read documentation properly. sorry rushing ask question simple.
eloquent assumes primary key field table named "id" default. change that, override $primarykey field corresponding field name in database table.
Comments
Post a Comment