-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Filtering on another database table #55
Comments
Looking at it briefly it looks like it's the way the relation is defined. Does it work when you update the public function contentFeature()
{
return $this->belongsTo('App\RepoModels\ContentFeature', 'sac_repo_db.content_features');
} |
Thanks for the quick reply. The following change:
creates this query which is closer but still missing
|
Ahhh, what happens when you remove that definition we just did in protected $table = 'sac_repo_db.content_features'; If that doesn't initially work, try it without the |
Brilliant - that did the trick. Many thanks indeed. Regards |
I am struggling to create a filter that uses a table "content_features" from another database "sac_repo_db".
If the user doesn’t select a filter the query is created correctly:
SELECT 'purchased_contents'.'id', 'purchased_contents'.'title', 'purchased_contents'.'description', 'sac_repo_db'.'content_features'.'content_type' FROM 'purchased_contents' inner join 'sac_repo_db'.'content_features' on 'purchased_contents'.'content_feature_id' = 'sac_repo_db'.'content_features'.'id' WHERE 'content_type_id' > '0'
However when a filter is applied the query omits the reference to the other database:
select 'purchased_contents'.'id', 'purchased_contents'.'title', 'purchased_contents'.'description', 'sac_repo_db'.'content_features'.'content_type' from 'purchased_contents' inner join 'sac_repo_db'.'content_features' on 'purchased_contents'.'content_feature_id' = 'sac_repo_db'.'content_features'.'id' where exists (select * from 'content_features' where 'purchased_contents'.'content_feature_id' = 'content_features'.'id' and 'content_type_id' in (6))
What it should create is this:
select 'purchased_contents'.'id', 'purchased_contents'.'title', 'purchased_contents'.'description', 'sac_repo_db'.'content_features'.'content_type' from 'purchased_contents' inner join 'sac_repo_db'.'content_features' on 'purchased_contents'.'content_feature_id' = 'sac_repo_db'.'content_features'.'id' where exists (select * from 'sac_repo_db'.'content_features' where 'purchased_contents'.'content_feature_id' = 'sac_repo_db'.'content_features'.'id' and 'content_type_id' in (6))
I realise this is rather a complex question, but I think I am probably missing something fairly simple to get the filter to construct the correct query. It works fine if I use
Any help would much appreciated.
PurchasedContentTableController.php
PurchasedContentFilter.php
PurchasedContent.php
ContentFeature.php
The text was updated successfully, but these errors were encountered: