Php (eval vs call_user_func vs variable functions ...)
<p>Even though there's some discussions regarding this issue I wanted to check on certain example what would be the best approach.<br>
Instead of using existing solutions I created my own persistence layer (like many do)
So my approach is also in question here.</p>

<p>For every table in db I have model class that has appropriate getters and setters and some mandatory methods. I also created only one generic DAO class that handles all types of model objects.<br>
So, for example to save any model object I instantiate genericDAO class and call save method that I pass model object as attribute.
Problem is that in runtime genericDAO class doesn't know whitch model object it gets and what methods (getters and setters) exist in it, so I need to call mandatory model class method that retrieves list of attributes as multiple string array.<br>
For example for every attribute there's array(table_column_name,attribute_name,is_string).  </p>

<p>When I call save function it looks like this:</p>

<pre><code>public function save(&$VO) {  
$paramArray = $VO->getParamArray();//get array of attributes
$paramIdArray = $paramArray[0];  //first attribute is always id
/*create and execute getId() and store value into $void to check if it's save or update*/
eval('$voId = $VO->get'.ucfirst($paramIdArray[1]).'();');  
...</code></pre> 

<p>Currently I'm using eval to execute those methods, but as it is well known eval is very slow.<br>
I'm thinking of changing that into call_user_func method<br>
Something like:</p>

<pre><code>$voId = call_user_func(array($VO, 'get'.ucfirst($paramIdArray[1])));
</code></pre>  

<p>But also there's other solutions. I can maybe use something like this  <pre><code>$method = 'get'.ucfirst($paramIdArray[1]));
$voId = $VO->$method();
</code></pre>  or else </p>

<pre><code>$method = 'get'.ucfirst($paramIdArray[1]));
$voId = $VO->{$method}();
</code></pre>  

<p>What would be the best way?</p>
