I have a data abstraction class that can get data from 3 different "Types" as they all have the same properties:
Ignoring the obvious faults in the code thats the basic gist of what I have.
Can I do something like this to kinda make a "Shortcut" class?
The reason I say this, is because in my methods, I'm dynamically calling classes through a function of mine:
Doing it to save on a large switch block.
So back to the question, can I do this? Or what can I do?
Code:
class Type { private $Tables = array('type1','type2','type3'); __construct($type,$id) { $db->query('SELECT * FROM `'.$this->Tables[$type].'` WHERE `id`='.$id); } }
Can I do something like this to kinda make a "Shortcut" class?
Code:
class FirstType { __construct($id) { return new Type(0, $id); } }
Code:
function getClass($class) { if ( class_exists($class) ) return new $class(); else return false; }
So back to the question, can I do this? Or what can I do?
Comment