2

I'm building a small analytics plugin and as such, I don't need the dateUpdated and uid columns in my records, but I dind't find any way of disabling them.

Currently I have tried:

  • Not setting them in the install::safeUp: doesn't work as Craft adds the attributes to the list and PDO complains "column not found dateUpdated"
  • Making my record directly extend Yii2's active record and not craft's one

Nothing worked.

Is there any clean solution to this?

Thanks a lot for your help!

2

This might not be the answer you were looking for, but I don't think you need to go to great lengths trying to achieve something that in my opinion is not necessary. While it might seem to be not "clean" to have database table columns that are not required by your application/plugin, consider that todays ICT infrastructure is powerful enough to not slow down due to a few additional columns in a database and its tables.

I would even consider it more risky trying to alter the "base" of Craft or the Yii framework than to live with a few autogenerated columns.

If you are very sensitive to performance and have many database requests, you might not want to use active record since its higher level of abstraction can come with a performance penalty in certain situations.

1
  • Yeah you're probably right, I believe I'm gonna opt-out of the active records pattern. Thanks for your help – ovesco 2 days ago

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.