Due to having to having to import data from an old non cake app and oddly built database table I need to pass paginate an array of records it is allowed to display – is this possible?
Normally I would reorganise the data into proper relationships etc but due to time scales etc this is not possible.
To give you more info – in my users table I have a field that contains a list of ID’s that relate to documents they are allowed to view. The field will contain something like
123,23,45,56,765,122,11.9,71,25
Each ID refers to a document the documents model. I know that normally you would create proper ACOs and AROs and let the ACL/Auth componant handle which users can access what but this isnt an option this time around. So I thought if I could do it via paginate/find it might be an option?
Any help would be really appreciated.
Thanks in advance
You wouldn’t pass it a list of IDs, you’d use the IDs in your paginate conditions – something like below.
(Code written off top of my head, so pardon any syntax errors…etc. It should give you the right idea/path at least):
When you pass an array as a condtion (eg.
'id'=>$arrayOfIds), it uses MySQLs “IN” – something like: