Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

skipAttributes on SELECT (Phalcon 2.x)

Is there such a thing as skipAttributes on the SELECT (not just insert/update)

All my models extend a BaseModel which have some basic fields like id, createDate, editDate, active.

Some of my tables do NOT have all these fields. During insert/update, the skipAttributes() are working fine but it blow up during any type of fetch. I was thinking of doing something like beforeSelect() something like that to hook into to maybe even do something like

unset($this->createDate);

Not really familiar with the Zephir code to look deeper

The obvious solution (not preferred) would be to create 2 abstract classes instead of one and do one more extend

Thanks, Chris



4.3k
Accepted
answer

Are you using independent column mapping? http://docs.phalconphp.com/en/latest/reference/models.html#independent-column-mapping

If you map the columns for each model, you shouldn't have any issues.



2.0k

Thanks! I am using some Annotation stuff (includes mapping the column fields) but manipulating the columnMap is the right way to go. I ended up creating an annotation @Skip and have the field not added to the columnMap -- this is a hack that I need to remove

Are you using independent column mapping? http://docs.phalconphp.com/en/latest/reference/models.html#independent-column-mapping

If you map the columns for each model, you shouldn't have any issues.



4.3k

The nice thing about the dev tools is that you can get it to map everything for you. The only complaint I have with devtools though is that all-models doesn't have "mapcolumn" or "trace" as possible parameters.