Open salain opened 3 years ago
Yes. You can use all the usual Query Builder methods intermixed with Relations methods.
Sorry, but could you give an example as I can not get it to work. If I have this and want to filter posts on year 2020:
$author = $authorModel->with('posts')->where('year', '2020')->findAll();
I get error column year not found in where clause
Maybe try 'posts.year'
instead? I cannot dig into this right now but you could try the CodeIgniter forums for help.
Adding the table name does not work as it adds the where clause to the main query. I will try to find a workaround for this.
Thanks
Ahh I see what you mean now. No, this is not currently possible, though we've had requests for handling content from join tables and this would overlap with conditional relationships. I will consider it a feature request.
Thanks. I have a basic workaround to suite my tests for now.
HI,
Is there anyway to add a WHERE clause to a relation? For example retrieve all authors details with all of their posts created in 2020.