S
S
sgidlev2021-08-09 11:45:40
PHP
sgidlev, 2021-08-09 11:45:40

How to pass conditions to json in order to decode them later in PHP and form an SQL query?

Tell me how it is better or more correct to implement the following:
1. Pass data through a request to json
2. The data must then be decoded in PHP
3. Based on this data, form an SQL query and select data

The problem is that the conditions are multi-component and contain AND, OR, >=, .......

For example, based on this condition, create json:

if ($dislocation->getInfType() === $this->infType &&
  $dislocation->getStatusTrip() === $this->statusTrip &&
  (
    (
      $progDeliveryDiffDis === DislocationDataProgDelivery::TODAY_DIFF ||
      $progDeliveryDiffDis === DislocationDataProgDelivery::TOMORROW_DIFF
    ) ||
    $dislocation->getRestDistance() <= 200
  )
)


In principle, the concept of GraphQl fits the syntax, but in any case, you need to spend a decent amount of time to convert this syntax and rules into an SQL query.

Tell me, can there be a simpler option or a ready-made solution?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question