Z
Z
zxcursed2021-06-13 21:50:09
PHP
zxcursed, 2021-06-13 21:50:09

What API can be raised to work with the database?

Good evening, tell me what API can be "pulled" for php, when the main work of the scripts will be related to the output of information from the database? Perhaps the question was raised incorrectly. never dealt with something like this before.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
rPman, 2021-06-13
@rPman

Once, where it was not critical, I did the backend as a primitive layer for the database and storing sql queries, i.e. the client in the request issued a request identifier and a list of its parameters in a named array, and the server returned the plate as is, the php code is almost a dozen lines plus a list of sql queries. If there are many requests at a time, introduce the possibility of sending them in a batch....

I didn't need it but I remember thinking about it
, что когда нужно выполнить серию запросов, пользующихся возвращаемыми данными друг друга, можно использовать перменные, указывая вместо значений идентификаторов их имена в каком-нибудь формате, пронумеровав и поименовав их
Например два запроса - FIRST:select b_id from table_a where id=123 и второй SECOND:select name from table_b where id={FIRST:b_id} тут в качестве параметров будут переданы FIRST:[id:123] и SECOND:[id:"{FIRST:b_id}"]

It’s a little more difficult with modification requests, the requests themselves are not complicated, but it will be necessary to somehow describe the restrictions, what can be deleted or edited and what can’t, in general, for the task, but just like with a data request for reading, the backend acts exclusively a simple layer to calls to methods of the sql driver (it is clear that you should not get to method calls, i.e. for example, after inserting insert records, you can immediately call lastInsertId and return it in the response, as well as check for errors and collect details (shove to the log and issue to the client)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question