私はさまざまなレポートデータを取得するすべての関数のメインコンテナとして使用しているレポートモデルを持っています。このレポートモデルは、別のレポート要件ごとに異なるテーブルへのアクセス権を持っている私の試みで、次のような機能Zend Frameworkどうすれば私のApplication_Model_Reportから別のテーブルクラスにアクセスできますか?
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フレームワークの頭の中で頭を上げようとするのを助ける必要があります。ありがとう。
と線131と22は何ですか?私はあなたのagentDailyCollections()がここで問題を引き起こしていると思いますか? – Fge