I'm very familiar with sqlite3 in php since years, now using PHP V 8.0.7 and SQLite V3.26
Also learning SQLite window functions (OVER clause)
I need to use User-Defined Aggregate Window Functions (sqlite3_create_window_function)
Already succeeded using sqlite3_create_function, as createFunction and createAggregate, either in PDO:: and SQLite3::, I used them for years too. But create_window_function is not documented in PHP, nor under PDO nor under SQLite3
And I get "Fatal error: Uncaught Error: Call to undefined method" when i call ceateWindowFunction, create_window_function or sqlite3_create_window_function
Can sqlite3_create_window_function be "hidden"? (already present in sqlite3.26 I check)
echo 'PHP Version: ' . phpversion(); //PHP Version: 8.0.7 $db = new SQLite3('mibdsqlite.db'); echo 'SQlite3 version: ' . $db->querySingle('select sqlite_version();');//SQlite3 version: 3.26.0 $db->createWindowFunction( ... );//Fatal error: Uncaught Error: Call to undefined method SQLite3::createWindowFunction() in folder/filename //same error using create_window_function or sqlite3_create_window_function
Is there a way to make it accessible using .htaccess or php.ini, load a PHP extension, etc? (I'm working on a shared hosting)
Thank you in advance
That is presumably because PHP doesn't have that function. In addition to the version of SQLite with that function, you will also need the version of PHP that knows how to call that function of SQLite.
(3) By RandomCoder on 2021-06-28 22:29:01 in reply to 1 [source]
PHP's SQLite interface has no method to call sqlite3_create_window_function at present. You will need to work with the PHP community to add such a feature or create an extension to do so (assuming that's possible).
Aside from what others have noted (that PHP doesn't currently support
sqlite3_create_window_function), the function documentation also states (emphasis mine):
The sixth, seventh, eighth and ninth parameters (
xInverse) passed to
sqlite3_create_window_functionare pointers to C-language callbacks that implement the new function.
I'm curious as to how you're expecting the PHP equivalent to work. What exactly are the parameters you're passing to
The PHP module runtime could provide the C functions that would call back into the PHP code written by the user, the same way it's implemented in DBD::SQlite, for example.
That's how it would have to be done, certainly, but I guess my point wasn't clear. When I asked the OP (presumably Mar Zama):
What exactly are the parameters you're passing to
I meant that literally: How are you using this hypothetical function? If the answer is "I haven't really thought that far yet", then how would Mar Zama implement sumint() in PHP with
Answering these questions goes a long way towards defining Mar Zama's requirements--and maybe suggest a alternative solution to a function that doesn't yet exist.
So, something like: $db->sqliteCreateWindow('sumint', 'sumintStep', 'sumintFinal', 'sumintValue', 'sumintInverse') where those strings are names of window function being defined, and functions user must write in php to implement it.
And, yes, it requires PHP/PDO modifications that are beyond my knowledge.
Thank you for your answers