Model best practices |
[eluser]sqwk[/eluser]
$var would be the name of the property, which in my case is the same as the column in the DB.
[eluser]Eric Barnes[/eluser]
[quote author="sqwk" date="1310540466"]The array is not the problem. foreach handles objects as well. Nothing is getting overwritten, it is just looping though. Ignore the explicit setters… simplified example. Code: class A_Model extends CI_Model { Yes but I am willing to bet (and could be wrong) if you var_dump($this) before your foreach you will see you are actually looping over tons of data. Not just your two vars in this example.
[eluser]sqwk[/eluser]
@eric: That's what I thought and is the reason why I posted this. Thought someone would find some speed problems etc. Just tested it though and I only get the actual properties that are defined in the model.
[eluser]Eric Barnes[/eluser]
[quote author="sqwk" date="1310542513"]@eric: That's what I thought and is the reason why I posted this. Thought someone would find some speed problems etc. Just tested it though and I only get the actual properties that are defined in the model.[/quote] I did say I could be wrong and didn't have time to actually test that theory on my own.
[eluser]Jaketoolson[/eluser]
why not overloading with __set? http://www.php.net/manual/en/language.oo...ng.members
[eluser]sqwk[/eluser]
Used __call to build implicit setter functions that I can override. |
Welcome Guest, Not a member yet? Register Sign In |