![]() |
Using static method to create objects
Wonder if anyone can help me with the syntax for this. I have created a class called Collective and with that class a public static method called getInstance which reads several rows from a mysql table and creates an object of class Collective for every row read. I;m not getting any major syntax errors when i run this but it just isnt working well the db call is working and returning what i expect but the object creation but isnt. Any advice? (PS - I'm just passing in joebloggs to test the class and i'm getting rows back from the database so no problem there).
Client Code: PHP Code:
PHP Code:
|
Review any typo!
Hi, dear Captain Merton!
I've run some tests on your script and have little to say! Your code is okay, the SingleTon Pattern is correct, but you typed the Constructor wrong: Code:
private function _contruct($colid, $colname)Code:
private function __construct($colid, $colname) |
Brilliant thanks Gilberto. In all my testing I could tell that it was not getting to the construct function but was throwing no error as i assume it was simply treating it as another class method. But I didnt ever consider the spelling being wrong. Thanks for taking the time to look it over. Cheers.
|
You're welcome!
Well, I did every possible test and, in fact, finding the spelling error was the last thing I did! |
| All times are GMT. The time now is 08:25 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0