开发者

PHP ORM's, multiple tables and efficiency

开发者 https://www.devze.com 2023-01-02 12:25 出处:网络
Let\'s say I have a data mapper function开发者_如何学Go that aggregates multiple tables and generates an object instance from that data. The mapper has a typical save() method which delegates to updat

Let's say I have a data mapper function开发者_如何学Go that aggregates multiple tables and generates an object instance from that data. The mapper has a typical save() method which delegates to update/insert.

When the mapper executes save - ideally it isolates object fields that have been modified, thus preventing the code from blanket bombing the database.

How would you go about this?


Store both the original and a working copy of the data in the object(s). If they differ, write them back.

While you could store just a hash of the original data, this gets messy if your underlying database is normalized and you allow changes to the primary key.

C.

0

精彩评论

暂无评论...
验证码 换一张
取 消