So i have been working with codeigniter for three years, and for database queries most of the time i use active records, and design database in a way that avoids complex queries .
But current project i am working on has recurring membership plans and i am saving them in a table with start and end date .
like
membership table
ID
memberid
startdate
enddate
other table is
members
Id
name etc
now at the time of login i have to do a joing with table members and membership but joins needs to return only recent entry for that member from membership table.
I can do it by simple queries first get the member and then membership recent row for that member and then do the comparison, but there would be case where i would need to use pagination and in that case i will need a single query of join.
which can do following.
logic
get member information from members table
whose (enddate+1 day) only for recent entry for that member from membership table is smaller than currentdate.
if the query can be done using active records that would be great help.
Any help would be greatly appreciated.
Thank You guys.