3v4l.org

run code in 300+ PHP versions simultaneously
<?php $metas = array( 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3' ); $limit = 10; $config = (object)array('recording_table' => 'recording', 'meta_table' => 'meta'); $join = array(); $params = array(); $types = ''; foreach ($metas as $key => $value) { $join[] = 'm.meta_key=? AND m.meta_value=?'; $params[] = $key; $params[] = $value; $types .= 'ss'; } // add the parameter for the `HAVING` check $params[] = count($metas); $types .= 'i'; // add the limit $params[] = $limit; $types .= 'i'; // make the query string $sql = "SELECT recording_id FROM {$config->recording_table} r JOIN {$config->meta_table} m ON m.recording_id = r.id AND (" . implode(' OR ', $join) . ") GROUP BY r.id HAVING COUNT(*) = ? LIMIT ?"; echo $sql . "\n"; print_r($params); print_r($types);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 18
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 18
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/eR6bL
function name:  (null)
number of ops:  49
compiled vars:  !0 = $metas, !1 = $limit, !2 = $config, !3 = $join, !4 = $params, !5 = $types, !6 = $value, !7 = $key, !8 = $sql
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    8     1        ASSIGN                                                   !1, 10
    9     2        CAST                                          8  ~11     <array>
          3        ASSIGN                                                   !2, ~11
   10     4        ASSIGN                                                   !3, <array>
   11     5        ASSIGN                                                   !4, <array>
   12     6        ASSIGN                                                   !5, ''
   13     7      > FE_RESET_R                                       $16     !0, ->18
          8    > > FE_FETCH_R                                       ~17     $16, !6, ->18
          9    >   ASSIGN                                                   !7, ~17
   14    10        ASSIGN_DIM                                               !3
         11        OP_DATA                                                  'm.meta_key%3D%3F+AND+m.meta_value%3D%3F'
   15    12        ASSIGN_DIM                                               !4
         13        OP_DATA                                                  !7
   16    14        ASSIGN_DIM                                               !4
         15        OP_DATA                                                  !6
   17    16        ASSIGN_OP                                     8          !5, 'ss'
   13    17      > JMP                                                      ->8
         18    >   FE_FREE                                                  $16
   20    19        COUNT                                            ~24     !0
         20        ASSIGN_DIM                                               !4
         21        OP_DATA                                                  ~24
   21    22        ASSIGN_OP                                     8          !5, 'i'
   23    23        ASSIGN_DIM                                               !4
         24        OP_DATA                                                  !1
   24    25        ASSIGN_OP                                     8          !5, 'i'
   26    26        ROPE_INIT                                     5  ~31     'SELECT+recording_id+%0A++++++++FROM+'
   27    27        FETCH_OBJ_R                                      ~28     !2, 'recording_table'
         28        ROPE_ADD                                      1  ~31     ~31, ~28
         29        ROPE_ADD                                      2  ~31     ~31, '+r%0A++++++++JOIN+'
   28    30        FETCH_OBJ_R                                      ~29     !2, 'meta_table'
         31        ROPE_ADD                                      3  ~31     ~31, ~29
         32        ROPE_END                                      4  ~30     ~31, '+m+ON+m.recording_id+%3D+r.id%0A+++++++++AND+%28'
   29    33        INIT_FCALL                                               'implode'
         34        SEND_VAL                                                 '+OR+'
         35        SEND_VAR                                                 !3
         36        DO_ICALL                                         $34     
         37        CONCAT                                           ~35     ~30, $34
         38        CONCAT                                           ~36     ~35, '%29%0A++++++++GROUP+BY+r.id%0A++++++++HAVING+COUNT%28%2A%29+%3D+%3F%0A++++++++LIMIT+%3F'
   26    39        ASSIGN                                                   !8, ~36
   33    40        CONCAT                                           ~38     !8, '%0A'
         41        ECHO                                                     ~38
   34    42        INIT_FCALL                                               'print_r'
         43        SEND_VAR                                                 !4
         44        DO_ICALL                                                 
   35    45        INIT_FCALL                                               'print_r'
         46        SEND_VAR                                                 !5
         47        DO_ICALL                                                 
         48      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.09 ms | 1016 KiB | 15 Q