I have a PHP process running as a result of a JavaScript AJAX request, which is potentially running for some time and will produce data from time to time. From a usability perspective, I'd like to be able to return data to the JavaScript as soon as it's produced, but this appears not to be possible.
My workaround is to write it to an SQLite database and have another PHP script that runs say once a sec (as a result of another AJAX request) to take the data produced so far and return that, thus allowing the user to be updated on progress in a more timely manner.
Assuming, then, that this is a reasonable approach, the data-writer needs to be able to append a string to the already existing contents of a row. I don't know SQL that well, but the following appears to work:
create table str_table (mystr string);
insert into str_table (mystr) values ("first part of string.");
update str_table set mystr = ((select mystr from str_table) || " Second part of string.");
Is there a more direct way to append to mystr?
The data-reader needs to get the contents of mystr and then clear it. I guess I can do:
begin transaction
select mystr from str_table;
update str_table set mystr = null;
end transaction
but is it possible to do that in a single statement?
Thanks.