I’m playing around trying to write a class for handling orm / database connectivity.
My plan is to have each model class extending an underlying class that has basic crud functionality.
I’m storing the table name and primary key name in static constants as PK & TABLE.
The problem is I can’t access the primary key name with the following without generating the ‘Paamayim Nekudotayim’ error.
$this->static::PK
I can do this:
$pk = static::PK
$this->$pk
and i can even do this:
$this->fields[static::PK]
but
$this->static::PK
just doesn’t seem to work
any thoughts, comments, etc., most welcome.
I’m guessing that construct is ambiguous and the interpreter doesn’t know what to do with it, hence the parse error. In other words, it doesn’t know if you mean this:
or this:
Both of which are valid, but work very differently (as you can imagine).
Enclose the constant access in curly braces and it’ll work: