How to set class variables dynamically?
<p>Consider the following code:</p>

<pre><code>class Project
{
    public $ProjectID;
}    
class Work
{
    public $WorkID;
}    

public function insert($pData, $tableName)
{
//generate insert here
    $pData-&gt;{$tableName . 'ID'} = $result-&gt;getId();
}

$p = new Project();
$w = new Work();
insert($w, 'Work');
insert($p, 'Project');

echo $p . ' -- ' . $w;
</code></pre>

<p>Now how would I go about setting the variable in a <strong>dynamic</strong> way? I'm building a data layer. The <code>$pData-&gt;{$tableName . 'ID'}</code> doesn't seem to work...</p>
