所以我有兩個表,一個Customers表和一個Companies表。我還創建了一個空的Employees表,我想用它作爲連接表。 這是我有關聯:(我希望客戶與他們各自的公司關聯) class Company < ApplicationRecord
has_many :employees
has_many :customers, :through => :employees
e
表在這書上的例子: https://book.cakephp.org/3.0/en/orm/associations.html#using-the-through-option class StudentsTable extends Table
{
public function initialize(array $config)
{
$this->belongs
我用一些虛擬數據創建了一個假想的場景。下面是3個基本表格,我正在尋找一個查詢來查找Mary查看了哪些房產/房產。 在這種情況下,Mary已經在格拉斯哥查看了1個房產單位。 表1:客戶 =====================
ID Name
=====================
5 Tom
6 Mary
7 John
表2:房產 =====================