cphalcon icon indicating copy to clipboard operation
cphalcon copied to clipboard

[ BUG ] Models with underscores

Open quasipickle opened this issue 13 years ago • 4 comments

Hi,

I have a DB table access_log, and a corresponding model Access_Log. When I call save() on Access_Log, I get the exception:

Table "access__log" doesn't exist on database when dumping meta-data for App\Access_Log

Note: Access_Log is namespaced in App

Note also that the inferred table name has 2 underscores.

However, if I define the getSource() method thusly:

public function getSource(){
    return 'access_log';
}

Everything works fine.

quasipickle avatar Jul 31 '13 18:07 quasipickle

Your model should be called AccessLog, without the underscore. It's the convention.

ronaldcastillo avatar Aug 01 '13 20:08 ronaldcastillo

Ah yes, I see the documentation now. I'm not going to close this though, as I wonder if this should be mentioned in the documentation somehow - just how Phalcon determines the table name to map a model to.

quasipickle avatar Aug 01 '13 20:08 quasipickle

Open the issue in the docs repo: https://github.com/phalcon/docs

ronaldcastillo avatar Aug 01 '13 20:08 ronaldcastillo

phalcon/docs#143

quasipickle avatar Aug 01 '13 20:08 quasipickle