【发布时间】:2014-10-30 14:31:35
【问题描述】:
我正在尝试通过标准 PHP 学习 OO/Zend 框架。我想尖叫并编写一个 mysql 查询而不是使用 TableGateway 方法。
我一直在关注教程并成功打印出一个表格和一些字段,尽管按照我这样做的方式,我完全不知道如何将它与另一个表格连接并打印出一些字段在那里。
例如。
表格字段 客户 IDx,公司 联系 Idx,名字
这是我的customersController,我假设工作在其中进行
namespace Customers\Controller;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
use Zend\DB\TableGateway\TableGateway;
class CustomersController extends AbstractActionController
{
protected $customersTable;
public function indexAction()
{
return new ViewModel(array('customer' => $this->getCustomersTable()->select()));
//return new ViewModel(array('customers' => $this->fetchJoin()->select()));
}
public function addAction()
{
}
public function editAction()
{
}
public function deleteAction()
{
}
public function getCustomersTable()
{
if (!$this->customersTable) {
$this->customersTable = new TableGateway (
'customer', //table name
$this->getServiceLocator()->get('Zend\DB\Adapter\Adapter')
);
}
return $this->customersTable;
}
}
我在正确的轨道上吗?
【问题讨论】:
标签: zend-framework2