Reputation: 9170
I am currently struggling with a problem where one has the following setup:
class Model
{
public $tableConnection = null;
....
}
Now there is a class which inherits Model.
class NewModel extends Model
{
public $tableConnection = array("belongsTo" => "otherModel");
...
}
What I would like to acchieve is to define tableConnection just by putting a definition into the child class (NewModel) in order to overwrite the original variable within the class Model.
NewModel should be as simple as possible without additional methods or functions, instead Model can include anything useful. Someone maybe recognized a similarity to the CakePHP Framework. I am trying to understand how those things can be acchieved. And maybe there is some PHP wizzard out there who knows how to deal with this :-)
Upvotes: 1
Views: 99
Reputation: 72289
It is working, please check here:-
<?php
class Model
{
public $tableConnection = null;
}
class NewModel extends Model
{
public $tableConnection = array("belongsTo" => "otherModel");
}
$obj = new NewModel();
print_r($obj->tableConnection);
?>
Output:-https://eval.in/509293
Upvotes: 4