Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Model name when table name has underscore [closed]

Tags:

php

cakephp

I have a table activity_logs What should I give the model name and model file name?

I have created the model file as activityLog.php and model class name as ActivityLog

But I couldn't retrieve the data.

like image 815
Ha Dev Avatar asked Mar 22 '23 21:03

Ha Dev


1 Answers

In cake php table names are plural and model names are singular. Table names with underscore are converted into camel case for naming models.

For example user_levels table will have model named as UserLevel:

UserLevel => user_levels

Even if you didn't create a model, Cake will let you use it and make one up on the fly for you, if you follow table names by above naming conventions.

If Cake "ignores" your model, it means it's making up another model on the fly, because you're not using the right name for the model you actually want

Looking at the generated SQL queries in debug = 2 helps

like image 117
Rajinder Deol Avatar answered Mar 24 '23 10:03

Rajinder Deol