我有一个报表模型,我将其用作获取各种报表数据的所有函数的主要容器。此报告模型具有以下功能
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;
}
public function getDbTable($dbTable)
{
if (null === $this->_dbTable)
{
$this->setDbTable($dbTable);
}
return $this->_dbTable;
}
public function agentDailyCollections()
{
//$db =
$sql = $this->getDbTable('Application_Model_DbTable_Groupsloandetails'`enter code here`)->select()
->setIntegrityCheck(false)
->from(array('gl' => 'groups_loan_details'), array())
->join(array('ml' => 'members_loan_details'), 'gl.id = ml.groups_loan_details_id',
array('SUM(ml.daily_payment) AS GroupDailyPayment'))
->join(array('m' => 'members'), 'ml.members_id = m.id', array('id AS ID', 'first_name AS MFirstName', 'surname AS MSurname'))
->join(array('g' => 'groups'), 'gl.groups_id = g.id', array('group_name'))
->join(array('u' => 'users'), 'gl.loan_officer = u.id', array('id AS OID', 'first_name', 'surname'))
->where('gl.loan_end >=?', date(Y.'-'.m.'-'.d))
->where('gl.occur = ?', 'Active')
->group('(u.id)')
->group('(g.group_name)')
->group('(m.id) WITH ROLLUP');
return $this->getDbTable()->fetchAll($sql);
}
public function groupsWithMembers()
{
$sql = $this->getDbTable('Application_Model_DbTable_Members')->select()
->setIntegrityCheck(false)
->from(array('m' => 'members'), array())
->join(array('g' => 'groups'), 'm.groups_id = g.id')
->group('(g.group_area_residence)')
->group('(g.group_name) WITH ROLLUP');
return $this->getDbTable()->fetchAll($sql);
}
在尝试根据不同的报表要求访问不同的表时,我将所需的表类的名称传递给getDbTable函数,期望它为我获取表的对象。它有点工作,但后来我收到以下错误信息
Warning: Missing argument 1 for Application_Model_Report::getDbTable(), called in D:\www\gepm\application\models\Report.php on line 131 and defined in D:\www\gepm\application\models\Report.php on line 22`enter code here`
我知道我正在做的事情根本不对,但不确定是什么。需要帮助的人只是试图了解这个对象/ zend框架的事情。感谢。
答案 0 :(得分:0)
我认为您错过了函数参数的默认值,尝试更改:
public function getDbTable($dbTable)
{
带
public function getDbTable($dbTable = null)
{