linkable icon indicating copy to clipboard operation
linkable copied to clipboard

Issue using Linkable across multiple databases.

Open vincent-fletcher opened this issue 10 years ago • 2 comments

It seems that the 'joins' syntax only supports specifying other databases by writing them manually into the 'table' field, for example:

'table' => 'other_db.users'

Linkable does not inject the database name into the 'table' query, so models which exist in different databases get queried out of the default database for the Model which is running the find query.

I believe this can be fixed by modifying line 152 of LinkableBehavior.php to:

$options['table'] = $_Model->schemaName . '.' . $_Model->table;

I've not tested this extensively but it appears to work within my application.

Any feedback would be appreciated.

vincent-fletcher avatar Feb 05 '15 04:02 vincent-fletcher

That could work, another option is to call $datasource->fullTableName($model)... Are you able to provide a patch for this?

lorenzo avatar Feb 05 '15 13:02 lorenzo

Yeah sure, should I just push it as a pull-request?

vincent-fletcher avatar Feb 17 '15 01:02 vincent-fletcher