Hi! I am trying to use an SQLite database to store a particular a particular type of pages, in this case attendees for an event. (We are using to SQLite in order to integrate smoothly with iPad check-off app.)
I am using the approach outlined in Content from a database | Kirby CMS, and for the most part it works great!
However, I now have a particular table of attendees with ~5000 rows, and the request, in the panel to the attendees
page, yields a 500 Internal Server Error.
EDIT:
- This only happens with the following plugin: GitHub - sylvainjule/kirby-pagetable: Display subpages in a flexible table section. Kirby 3 only.**
- If I use
type: pages
andlayout: table
in the blueprint, the problem disappears. - However, with the pagetables plugin, I can sort the table by clicking on the column headers, which is something I really want to be able to do.
I get the following response message in the console:
file_put_contents([...]/uuid/page/0M/7bE5U957mpuQ2M.cache):
Failed to open stream: Too many open files
When I disabled UUID’s, I got a 502 Bad Gateway Error instead.
My models/attendees.php
goes as follows, slightly abbreviated:
class AttendeesPage extends Kirby\Cms\Page
{
public function children()
{
$attendees = [];
$allAttendees = getAttendeeDatabase()->table('attendees')->all();
foreach ($allAttendees as $attendee) {
$attendees[] = [
'slug' => $attendee->slug(),
'template' => 'attendee',
'model' => 'attendee',
'content' => [
'name' => $attendee->name(),
'slug' => $attendee->slug(),
// Some more fields here.
];
}
return Pages::factory($attendees, $this);
The getAttendeeDatabase
function is defined in a plugin and goes roughly like this:
public function getAttendeeDatabase()
{
$database = new Database(
[
'type' => 'sqlite',
'database' => $this->root() . '/attendees.sqlite'
]
);
// Code here for creating the table if it does not exist
return $database;
}
In the above-mentioned guide it says:
With lots of entries it would also become necessary to work on a custom collection for the result set that would only fetch the rows it really needs, but this would be more complex.
Is there an example of this anywhere? I think this is what I need, but I’m not sure. Any help is much appreciated!