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

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

  •  02-06-2022
  •  | 
  •  

Question

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

Était-ce utile?

La solution

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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top