Extending PHP method/property modifiers

Coding Critique is the place to post source code for peer review by other members of DevNetwork. Any kind of code can be posted. Code posted does not have to be limited to PHP. All members are invited to contribute constructive criticism with the goal of improving the code. Posted code should include some background information about it and what areas you specifically would like help with.

Popular code excerpts may be moved to "Code Snippets" by the moderators.

Moderator: General Moderators

User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Extending PHP method/property modifiers

Post by VladSun »

koen.h wrote:Going the performance route, I'm going to reask the following question:

"Do you have to get them out of the db one by one and check them, or can you do it in one query (eg SELECT * FROM posts WHERE allowed to view)?"

I think the solution will work when you have the object, but how do you know what objects you can retrieve from a database?
Still figuring out the best way to do it :) Give me some more time :)
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Extending PHP method/property modifiers

Post by VladSun »

Jenk wrote:Something other than the performance topic.. use class constants instead of global. Global dependencies are a smell. :)
Yeah, I do use class constants. These "defines" were just an example trash :)
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Extending PHP method/property modifiers

Post by VladSun »

pytrin wrote:Just saw this, very very nice. I'm not sure if I'll have use for this in any upcoming project, but for stuff like financial systems this could be pretty useful.

Regarding performance, how about caching permissions for the lifetime of the process? (ie, once a method/property has been approved/denied always return the same value using a simple hash table). Might include a flag to indicate whether to allow caching or not. I would imaging APC could improve this a lot as well.

nice going Vlad! :)
Thanks, pytrin :)
I'm still not very interested in performance issues, rather than the theory and implementaion issues (I just want to make it ALIVE :) )
There are 10 types of people in this world, those who understand binary and those who don't
Post Reply