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