Quantcast
Channel: Steven Brown
Viewing all articles
Browse latest Browse all 10

An Easier Way to Instantiate Models in Zend Framework Controllers

$
0
0
I get sick of having to type this: $someTable = new Some_Table(); $someTable->someMethod(); Since PHP can’t chain on instantiation this gets very annoying. I added this to my base controller (which all of my controllers extend): public function __get($name) { if (substr($name, -5) == 'Table') { $tableName = ucwords(substr($name, 0, -5)) . '_Table'; return new [...]

Viewing all articles
Browse latest Browse all 10

Trending Articles