How does PHP ActiveRecord correlate the singular class name to the table name?

StackOverflow https://stackoverflow.com/questions/17608243

  •  02-06-2022
  •  | 
  •  

Вопрос

I'm still a bit confused by how the following works:

your table name would be "people" 
class Person extends ActiveRecord\Model {}

So thats what i did with my table: posts.

class Post extends ActiveRecord\Model{}

At no point did I have to specify Post is actually equal to the table posts. So where/how does this magic happen? How would I override it if need be?

What about in instances like:

class fish = table fish
class goose = table geese  

Thanks

Это было полезно?

Решение

Use the static $table_name in your model, see php-AR conventions.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top