I have this (shortened):
abstract class MyModel
{
const DBID = "";
const TOKEN = "";
public function getDB()
{
if(!$this->_DB)
{
$c = get_called_class(); // doesn't work pre php 5.3
echo $c::DBID; // doesn't work pre php 5.3
echo $c::TOKEN // doesn't work pre php 5.3
}
return $this->_qb;
}
The problem is that get_called_class() and the $c::DBID/TOKEN doesn’t work in php < 5.3
Is there a way I can accomplish the same task from within the abstract class that is compatible with 5.2.9?
EDIT:
Constants aren’t really meant to be changed throughout object instantiations, you may want to consider member variables instead.
Abstract classes cannot be instantiated directly. You could create a child class to extend your abstract class, then make the call to getDb().