ianaldrighetti / queryer

A simple, easy to use PHP database abstraction layer.
Other
0 stars 0 forks source link

Add SQLite3 driver #4

Open ianaldrighetti opened 10 years ago

ianaldrighetti commented 10 years ago

The title says it all!

ianaldrighetti commented 10 years ago

Been doing some research into the SQLite3 extension in PHP. It seems as though it is missing some functionality due to the SQLite API itself, such as the number of rows in a result set: http://www.webdeveloper.com/forum/showthread.php?244098-RESOLVED-mysql_num_rows-equivalent-for-sqlite3.

This could be emulated either by iterating through the result set then resetting the pointer, or modifying the query and using a COUNT(*). This might be faster and less memory intensive, but could result in errors if the select expression is complicated. I should probably do some tests to see what's faster.

Also, there is no seek in the SQLite3Result, but that's easy to emulate by simply resetting then fetch until we get to the correct offset. I must be careful though in case an attempt to seek results in an out of bounds (offset doesn't exist). It is likely that with mysql_data_seek if an attempt to seek to a nonexistent row it simply leaves it alone. So it must check to see if the offset is valid first, likely by using the getNumRows method.