【发布时间】:2023-03-12 17:35:02
【问题描述】:
我希望我以一种可以理解的方式提出这个问题。我一直在开发一个处理 1 个表 (jobschedule) 的应用程序。所以,我有models/Jobschedule.php、models/JobscheduleMapper.php、controllers/JobscheduleController.php、view/scripts/jobschedule/*.phtml 文件
所以在我的控制器中我会做这样的事情:
$jobnumber = $jobschedule->getJobnum();
$jobtype = $jobschedule->getJobtype();
$table = $this->getDbTable();
public function listAction()
{
$this->_helper->layout->disableLayout();
$this->view->jobnum = $this->getRequest()->getParam( 'jobnum', false );
$this->view->items = array();
$jobschedule = new Application_Model_Jobschedule();
$jobschedule->setJobnum( $this->view->jobnum );
$mapper = new Application_Model_JobscheduleMapper();
$this->view->entries = $mapper->fetchAll ( $jobschedule );
}
然后在我的映射器中我执行以下操作:
$resultSet = $table->fetchAll($table->select()->where('jobnum = ?', $jobnumber)->where('jobtype = ?', $jobtype) );
$entries = array();
foreach ($resultSet as $row) {
$entry = new Application_Model_Jobschedule();
$entry->setJobnum($row->jobnum)
->setJobtype($row->jobtype)
->setJobdesc($row->jobdesc)
->setJobstart($row->jobstart)
->setJobend($row->jobend)
->setJobfinished($row->jobfinished)
->setJobnotes($row->jobnotes)
->setJobid($row->jobid);
$entries[] = $entry;
}
return $entries;
}
然后在我看来,我可以操纵 $entries。好吧,我现在遇到的问题是还有另一个名为“jobindex”的表,其中有一个名为“jobno”的列。 'jobno' 列与 'jobschedule' 表中的 'jobnum' 列保持相同的记录。我需要在“jobindex”表中找到“store_type”列的值,其中jobindex.jobno = joschedule.jobnum(例如,1234 是jobno/jobnum)。有人可以在这里帮助我吗?我需要创建一个 jobindex 映射器和控制器吗?如果是这样,那就完成了......我只是不知道如何同时操作两个表并获取我需要的记录。以及将该代码放在哪里...在我的控制器中?
【问题讨论】:
标签: zend-framework zend-db zend-db-table