Hello all,
On the Zend Quick Start Guide that I’m more or less following, here: Zend Framework: Documentation: Create a Model and Database Table - Zend Framework Manual
They advice, among others, the following steps:
-
build a data source class that will access our data source by using Table Data Gateway pattern)
-
build a data mapper - that will connect our datasource to our model
-
build a model
Let’s suppose our Table Name is Foo.
Inside this Data Mapper we have this method:
class Application_Model_FooMapper
{
protected $_dbTable;
public function setDbTable ($dbTable)
{
if (is_string($dbTable)) {
$dbTable = new dbTable();
}
if (!$dbTable instanceof Zend_Db_Table_Abstract) {
throw new Exception('Invalid Table Data Gateway Provided');
}
$this->_dbTable = $dbTable;
return $this;
}
}
What I’m not getting is:
If the Table Data Gateway tell us to have one class per Table, and if the Mapper should point our Data Source to our Model, we may suppose we should have a Data Mapper per table as well, correct ?
If we should have a Data Mapper per table, then I don’t understand why do we need, on the method above, to have $dbTable instead of $foo ? I know that we may have whatever name we want on our variables. I’m aware of that but, for some reason, the quick start guide author have choose a more broader name and I’m not understanding the logic.
Can we put other table names on this Mapper? If we can, then, the class name makes no sense…
Kind of lost here, and I hope someone could clarify this for me.
Thanks a lot.