开发者

hiding model data based on id's existance in another table

开发者 https://www.devze.com 2022-12-15 20:05 出处:网络
I\'ve got a somewhat complicated question for you cakephp experts. Basically, I have created a db table called \"locations\". Every month I will get this table sent to me in csv format from a client.

I've got a somewhat complicated question for you cakephp experts.

Basically, I have created a db table called "locations". Every month I will get this table sent to me in csv format from a client. Unfortunately, instead of updating this table, I will have to empty it and reimport all of the records. Unfortunately, I cannot alter this table at all.

Functionality wise, users will have the ability to look at a display of these records, and be able to choose to hide certain ones. This "hidden" attribute must be persistent and survive the month to month purging of all records.

I had all of this working yesterd开发者_运维百科ay. What I did was, create a separate table called location_properties (columns were: id(int), location_id(foreign key), is_hidden(boolean)). When showing these records, it would simply check to see if "is_hidden==true".

This was all well and good(AND WORKING!), but then my boss kind of gummed up the works. He told me to delete the "is_hidden" column from the table because it would be more efficient. That I should be able to simply check for the existence of the location_id to hide or show it.

It doesn't appear to be quite that simple. Anyone know how I can pull this off? I've tried everything I can think of.


Your boss is wrong.

It's more efficient to add your column, than it is too delete and re-import the locations every month.

Did he say it was less efficient, or did you do an actual benchmark to see if its harms performance too much?


At first glance I see 2 solutions:

1) add a condition array('Location.id' => 'NOT NULL')

2) change join type to right join

I hope this helps

0

精彩评论

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