Class method returns object from a class that uses methods/properties from the higher class. How?
<p>I'm trying to achieve a simple behavior in my code, but i can't think of a decent way of doing it. Take a look at what i'm trying to do: </p>

<pre><code>$db = new Database('mydb');
$db-&gt;createTable('sample');

$myTable = $db-&gt;getTable('test');
$myTable-&gt;insert($data);
$myTable-&gt;insert($data);
$myTable-&gt;edit('2', $data2);
$myTable-&gt;remove('1');
</code></pre>

<p>getTable is a method of the <strong>Database</strong> class, that returns an object of the <strong>Table</strong> class. The <strong>Table</strong> class has table-operation-specific methods, such as insert, edit and remove. The <strong>Database</strong> class has important methods that <strong>Table</strong> should be able to use, such as exec and query. It also should be able to access properties from <strong>Database</strong>, such as $this->pdo.</p>

<p>Should <strong>Table</strong> extend <strong>Database</strong> or should <strong>Database</strong> have static methods? <strong>Table</strong> uses several methods from <strong>Database</strong>. Is there a design pattern i can use to implement this? A Factory? </p>
