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

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

  •  02-06-2022
  •  | 
  •  

Pergunta

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

Foi útil?

Solução

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top