SQLite Forum

Question about SELECT in PHP
Login

Question about SELECT in PHP

(1) By BenFringer (benfringer) on 2021-01-14 03:02:59 [link] [source]

Hello,

this is my first attempt at sqlite3 with php under windows.

My code is

$db = new SQLite3('test.sqlite');

$result = $db->query("SELECT * FROM test");

while ($row = $result->fetchArray()) {

echo $row['name'] ."-";

}

sleep(2);

Query is fine, I get all data displayed on the web page after the 2 second delay. I then run this query on 2 web pages and the 2nd page will appear 2 seconds after the first page is done. So after 4 seconds.

Is this normal or should a read be close to the same time regardless of how many clients are connected?

(2) By J. King (jking) on 2021-01-14 03:24:03 in reply to 1 [source]

This is a PHP question more than it is an SQLite question, I think. I don't suppose you're using the built-in PHP Web server for this? It's single-threaded and can only serve one request at a time.

(3) By BenFringer (benfringer) on 2021-01-14 03:55:09 in reply to 2 [link] [source]

Hi,

I am using lighttpd as the web server.

(4) By Stephan Beal (stephan) on 2021-01-14 04:02:25 in reply to 1 [link] [source]

Is this normal or should a read be close to the same time regardless of how many clients are connected?

You might (might - just speculating) eliminate that delay if you finalize the statement ($result) before sleeping. How that's done in the PHP API you're using is anyone's guess - you'll need to see the PHP-side docs for that.

(5) By BenFringer (benfringer) on 2021-01-14 04:10:20 in reply to 4 [link] [source]

Thanks to both. Just wanted to make sure that this was not an sqlite behaviour