-
Hello, Is there any chance that you could add at least one documentation for database integration (SQLite for instance?). I've tried integrating it but simply failed, the query runs fine but the response doesn't run and is simply stuck (later killed due to 60 seconds limit of the process). // Edit: not sure if it's Windows related. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 0 comments 7 replies
-
@divine Thanks for bringing this up, excellent question! I'm glad to hear you're interested and already support Framework X as a sponsor, so here's an excerpt form the upcoming documentation: $factory = new Clue\React\SQLite\Factory();
$db = $factory->openLazy('count.db', null, ['idle' => 0.001]);
$app->get('/count', function (ServerRequestInterface $request) use ($db) {
return $db->query('SELECT COUNT(*) AS count FROM hits')->then(function (Result $result) {
return new Response(200, ['Content-Type' => 'text/plain'], $result->rows[0]['count'] . "\n");
});
}); We're actually working on this very section in the documentation as we speak, but covering all the nasty details and possible options actually takes a fair amount of time, so the finished documentation might still take a while. I hope the above gist helps you get started! Both the SQLite and MySQL client implementations have an idle time they use to keep a pending database connection alive in case you send another query within this period. If you're using the built-in web server, you can take advantage of this and have faster response times because the connection will be reused. However, if you're using this behind a traditional web server, it may actually keep the loop running and not end the pending request, thus slowing down the complete response. Given using this behind traditional web servers is becoming increasingly more common, I'm working on assigning better defaults for the upcoming versions of both database implementations 👍 |
Beta Was this translation helpful? Give feedback.
@divine Thanks for bringing this up, excellent question!
I'm glad to hear you're interested and already support Framework X as a sponsor, so here's an excerpt form the upcoming documentation:
We're actually working on this very section in the documentation as we speak, but covering all the nasty details a…