Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

Public/private Properties

$
0
0
Hi!

I have a small problem here and I'm not sure how to handle it.
I have an Active Record model class callsed User. The db table has an attribute "active". Therefore, you can access a property in User class like $User->active.

What I'd like to do now is to disable or disallow direct property access. In normal circumstances I'd define $active property as private but since Yii doesn't work that way - I can't. If I define it as private, it doesn't get set when I load object properties via i.e. findByPK().

The bottom line is - how can I enforce accessing this kind of property only through getters and setters and not directly?

Any suggestions?
Thanx.

Viewing all articles
Browse latest Browse all 18717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>