You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am looking through the Records but cannot see anyway to recreate a record set from an array of records.
My use case is that I need to get 100 results from the database, but also require all of the information on the page itself (from all results). It sounds weird, but it is needed.
Anyway, the issue currently is that running the same query twice (once wiht, and once without the limit) is pointless, since i have to get all the results anyway, so getting the same results once and then using lithium to limit would be good. Once i get the results out I can convert the object to array (using RecordSet::toArray(), but I cannot find a way to do Records::toSet() or anything like that.
All of the rest of the code expects lithium recordset objects, so getting it back to a recordset is required.
Is there a way to do it?
The text was updated successfully, but these errors were encountered:
There is, and while it's not quite as simple as passing in an array, if you're on PHP 7, you can still do it in one line using generator delegation. Basically, you need to wrap your Record array in an iterator, and pass it like so: new RecordSet(['result' => $iterator]).
I am looking through the Records but cannot see anyway to recreate a record set from an array of records.
My use case is that I need to get 100 results from the database, but also require all of the information on the page itself (from all results). It sounds weird, but it is needed.
Anyway, the issue currently is that running the same query twice (once wiht, and once without the limit) is pointless, since i have to get all the results anyway, so getting the same results once and then using lithium to limit would be good. Once i get the results out I can convert the object to array (using RecordSet::toArray(), but I cannot find a way to do Records::toSet() or anything like that.
All of the rest of the code expects lithium recordset objects, so getting it back to a recordset is required.
Is there a way to do it?
The text was updated successfully, but these errors were encountered: