Bindings with setBindingKey not working


#1

Hello,
I have a problem with binding two tables by using setBindingKey.

I’m using a table with appointments and one with details. In the table “appointments” i’m defining a date range the appointmentDetails are valid for. Now I want to connect the tables with the column “configurationId”.
You can see the screenshots of the tables.

I changed my Tables to this configuration. Before didn’t had a configurationId and the Details where linked by the primary key. It worked well. But I want to reuse the Details so i added a configurationId.

When I Use bindingkey the Join is not executed on the database. How can I link them together?

Here are my table-classes:

class AppointmentsTable extends Table
{
    public function initialize(array $config)
    {
        parent::initialize($config);

        $this->table('appointments');
        $this->displayField('id');
        $this->primaryKey('id');  
        $this->hasMany('AppointmentDetails')->setForeignKey('appointmentId')->setBindingKey('configurationId')->setJoinType('LEFT');
        /*        
        $this->hasMany('AppointmentDetails', [
               'foreignKey' => 'appointmentId',
               'bindingKey' => 'configuraionId'
        ]);*/
        $this->belongsTo('Rooms',
        		['foreignKey' => 'roomid',
        		'joinType' => 'LEFT']);
        
    }
}

class AppointmentDetailsTable extends Table
{
public function initialize(array $config)
{
    parent::initialize($config);

    $this->table('appointmentDetails');
    $this->displayField('id');
    $this->primaryKey('id');        
    $this->belongsTo('Appointments')->setForeignKey('appointmentId')->setBindingKey('configurationId')->setJoinType('LEFT');
}
}