I'm pulling data from a table called Visits and I want to get room information as well. The cell Visits.room_id references Rooms.id, however, CakePHP is using Visits.id instead which I'm assuming is because it's the primary key.
Here are the tables
Visits - id is primary key. I even tried setting room_id as a foreign key when creating the table
id | guest_id | room_id | arrival_date | departure_date
Rooms - id is prmary key.
id | description | max_occupancy
So basically it's doing the following in a query
where Visits.id = Rooms.id
Instead of
where Visits.room_id = Rooms.id
In my Visit Model I have the following
public $hasOne = array(
'room' => array(
'className' => 'room',
'foreignKey' => 'id'
)
);
And here's an example of a query from the VisitsController
$visits = $this->paginate('Visit', array(
'arrival_date >=' => $date
)
);
$this->set(compact('visits'));
Is there any way I can tell CakePHP to use Visit.room_id instead of Visit.id?