How to create a model when the database table contains hyphens?
P粉007288593
2023-08-31 14:08:40
<p>I have tables with hyphens in my database, for example "user-cars". I can't change the name to "user_cars". Is there a way to name the model "user_cars" but have it reference the "user-cars" table? I tried <code>@@map("user_cars")</code> but it didn't work. </p>
According to the documentation, you need to map the model to the underlying table name. You tried
user_cars
, but did you tryuser-cars
? If your table name isuser-cars
, then you should map it to your model like this: