add tag
Anonymous 1631
I am experienced in PHP with PostgreSQL. For complicated reasons, I now have no choice but to only have PHP + MySQL database support with my webhost. I last used MySQL in the early 2000s and no longer have any knowledge of how to use its functions and what its SQL syntax is like, so my PG knowledge is useless here.

The only thing I will be using MySQL for on the live website is to store JSON blobs submitted by users, and then fetch them later for local processing.

I'm trying to do the following would-be-simple-to-me-if-in-PG things:

1. A script which does nothing but connect to the MySQL database and creates a table with a single text field for holding a JSON blob (converted to a string) of arbitrary length. It probably should also have an "id" primary key column of type "bigserial" or whatever the MySQL version of that might be.
2. A script which INSERTs a JSON blob as text into the above table as a parameterized query.
3. A script which returns all existing records (perhaps limited to 1000 at most at once) from the table as an array of strings and then deletes all the fetched records.

Everything else I can handle. I'm only asking you for help with the practical MySQL function and query syntax.

At first, I wanted to use files and not involve any database at all for this, but it proved difficult to say the least, since it has to deal with potentially massive concurrent writing and the risk of corrupting/losing data. It seems like doing it with MySQL, even though I have to ask about it, is the least nightmarish way after all.

I'm trying to do this with minimal PHP code and no dependencies other than what's built in (mysqli or PDO).

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.