开发者

mysql don't return results if not from statement but from INDEX table or something

I think my question was a little confusing.....It confused me :)

Working on a media site as a take-over project and it has a custom CMS. The client wants the ability to activate/deactivate media....sort of like Wordpress's publish/unpublish feature.

Instead of digging through all the code looking for mysql queries (which I'm not opposed to), I was wondering if you can add a sort of INDEX to a table that won't let it return result row开发者_如何学运维s if that rows "active" column = let's say 0.

Just trying to be lazy and learn something at the same time, heh.

I don't need examples of queries to make it happen, btw.


What you describe is called a "view". Here is a page describing how to create them in MySQL: http://dev.mysql.com/doc/refman/5.0/en/create-view.html. However, in most cases you will still have to alter your code to use the view instead of the table.


You can consider create a view (which contains active record only)

AND swap the view name to actual table name instead, so you can achieve the negative filtering without changing any of your source code.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜