【发布时间】:2018-10-05 19:58:00
【问题描述】:
我有这张桌子:
客户[id, name, surname, phone, text, balance, created]
service_types[id, title, price, length, is_subscription, created]
customer_service_types[id, customer_id, service_type_id, price, created]
在view.ctp 中,我想查看分配给当前客户的所有Services。
Bake 在CustomersController.php 中创建了这个view function
public function view($id = null)
{
$customer = $this->Customers->get($id, [
'contain' => ['CustomerServiceTypes']
]);
$this->set('customer', $customer);
}
在view.ctp 中,我想显示service_type -> title,所以我尝试这样做:
<td><?=$customerServiceTypes->service!==null ? h($customerServiceTypes->service->title) : '' ?></td>
但它总是显示空白。我怎样才能改变它才能工作?
【问题讨论】:
标签: php join cakephp model-view-controller associations