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.
Below are my code for my class Member. It has been running really slow in my site. I need some comments and suggestion on how to speed up the execution of this code. Thanks.
laics wrote:Yes the columns are indexed. I do it as class thought it is easier to maintain. May I know whether you have better suggestion on how should modify the class? o should i separate them into different methods respectively? Thanks.
The class has no properties, only one function, and you are calling it statically. There is no difference between what you are doing and a plain function except a little overhead for the static class call.
The class has no properties, only one function, and you are calling it statically. There is no difference between what you are doing and a plain function except a little overhead for the static class call.
Is it means that i can solved this issue by separating all the method like getfirstname(), getsecondname, getuserid and so on?
Like others have mentioned -- the slowness lies in the query. Why are you using LIKE? Why not a straight equals?
laics wrote:Yes the columns are indexed.
You said columns (plural). Most often the only field that should be an index is the primary key. Having too many indexes is just as harmful as none at all.
You said columns (plural). Most often the only field that should be an index is the primary key. Having too many indexes is just as harmful as none at all.
So which fields are indexed?
Is the equal execute faster than the LIKE? Can you explain furthermore on that. It is new to me.
Yes.. I have indexed the name column too. is it fine?
Thanks.
laics wrote:Is the equal execute faster than the LIKE? Can you explain furthermore on that. It is new to me.
Yes.. I have indexed the name column too. is it fine?
Thanks.
Thanks for your reply. $uid is come from $_GET too. May I know how to solve this problem to secure it from open attack? $uid is retrieved after an encryption from $_GET. Thank you.
Thanks for your reply. $uid is come from $_GET too. May I know how to solve this problem to secure it from open attack? $uid is retrieved after an encryption from $_GET. Thank you.